/* @(#)GSOrderProcessor.java
 *
 * Project: GS
 *
 * Modify Information:
 * =============================================================================
 *   Author       Date       Description
 *   ------------ ---------- ---------------------------------------------------
 *   Simonyi Peng 2006-2-7    建立
 *   Jenny   Li   2006-2-16  添加方法getOrderAndManufacture，submitOrders,getManufactureByOrderId,
 *                                 getQueryOrderSql,getOrderByOpt
 *   Road Zheng   2006-2-17  修改方法orderStatusModify， orderCancel
 *   Jenny   Li   2006-2-21  添加方法getOrderAndOrderDetail,submitOrderDetailToApep
 *   Jenny   Li   2006-3-7   添加方法getOrderDetailForNonFlatProvider，submitOrderDetailForNonFlat
 *   Jenny   Li   2006-3-14  修改方法getSubmitOrderAndDetail参数为GSOrderSubmitVO
 *   Jenny   Li   2006-3-15  添加方法getOrderDetailByOpt，formateDate
 *   owen   xia   2006-3-16  添加方法getCancelOrderAndDetail，modifyCancelOrderTask,
 *   Simonyi Peng 2006-3-16  修改方法getOrderDetail
 *   owen   xia   2006-3-18  修改方法getBusCancelOrderAndDetail,modifyCancelBusOrderTask
 *   Jenny   Li   2006-3-18  添加方法getOrderDetailOfBus，修改submitOrderDetailToApep
 *   Jenny   Li   2006-3-19  添加方法getOrderDetailForRecordSignInfo,saveSignInfoOfNonFlat,修改方法getOrderDetailForNonFlatProvider
 *   Jenny   Li   2006-3-20  修改方法getOrderDetailForModify传入的参数，updateOrderDetailByType方法名改为updateOrderDetail
 *   Jenny   Li   2006-3-21  修改方法modifyCancelBusOrderTask，submitOrderDetailToApep,updateOrderDetail
 *   Jenny   Li   2006-4-12  修改方法submitOrderDetailToApep,modifyCancelBusOrderTask,updateOrderDetail
 *   Jenny   Li   2006-4-28  添加方法saveUnBalanceModSignInfoOfNonFlat,getEmergencyOrderAndDetail
 *                              getEmergencyOrderDetailByOrderId,getSignedDetail,getOrderDetailForBalanceSignInfo
 *   Jenny   Li   2006-5-10  添加方法getBalancedAssociatedOrderDetail,exportBalancedDetail,writeFile，exportUnbalancedDetail
 *   Jenny   Li   2006-5-24  添加方法getHistoryOrderDetail
 *   Jenny   Li   2006-6-1   修改方法getOrderDetailByOpt,getOrderDetailForStatusTrace为新增显示供应商字段
 *   Simonyi Peng 2006-6-1   修改方法getOrderDetailOfBus,getOrderDetailForRecordSignInfo为新增显示保质期字段
 *   Jenny   Li   2006-6-2   修改方法writeFile增加显示按同一供应商或订货单位统计金额以及总金额
 *   Jenny   Li   2006-6-5   修改方法saveUnBalanceModSignInfoOfNonFlat新增功能将修改内容提交到交易平台
 *                           添加方法submitModifiedSignInfoToApep
 *   Simonyi Peng 2006-10-23 提供对供应商"仓储中心"的特殊处理和显示
                                 修改getOrderDetailListForBalanceAudit方法，在结算审核菜单提供对供应商"仓储中心"的支持
 * Copyright Notice:
 * =============================================================================
 *    Copyright (c) 2001-2006 Beijing HiTRUST Technology Co., Ltd. 1808 Room,
 *        Science & Technology Building, No. 9 South Street, Zhong Guan Cun,
 *        Haidian District, Beijing ,100081, China All rights reserved.
 *
 *    This software is the confidential and proprietary information of
 *        Beijing HiTRUST Technology Co., Ltd. ("Confidential Information").
 *        You shall not disclose such Confidential Information and shall use it
 *        only in accordance with the terms of the license agreement you entered
 *        into with HiTRUST.
 *
 * Warning:
 * =============================================================================
 * 
 */
package com.hitrust.gs.business;

import java.io.IOException;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;

import jxl.Workbook;
import jxl.write.Label;
import jxl.write.WriteException;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.HSSFColor;

import system.LoginContext;
import system.base.MyProduct;

import com.hitrust.gs.bean.GSBalanceMsgBean;
import com.hitrust.gs.bean.GSOperatorBean;
import com.hitrust.gs.bean.GSOrderAnaDetailAndCategoryBean;
import com.hitrust.gs.bean.GSOrderAnaDetailBean;
import com.hitrust.gs.bean.GSOrderBean;
import com.hitrust.gs.bean.GSOrderDetailBean;
import com.hitrust.gs.bean.GSOrganizationBean;
import com.hitrust.gs.dao.GSBalanceMsgDAO;
import com.hitrust.gs.dao.GSBusOrderDAO;
import com.hitrust.gs.dao.GSManufactureDAO;
import com.hitrust.gs.dao.GSOperatorDAO;
import com.hitrust.gs.dao.GSOrderDAO;
import com.hitrust.gs.dao.GSOrderDetailDAO;
import com.hitrust.gs.dao.GSOrganizationDAO;
import com.hitrust.gs.dao.GSProviderDAO;
import com.hitrust.gs.form.GSBalanceDetlOptForm;
import com.hitrust.gs.form.GSOrderDetailQueryForm;
import com.hitrust.gs.form.GSOrderReceiveQueryForm;
import com.hitrust.gs.form.GSOrderStatusTraceQueryForm;
import com.hitrust.gs.form.GSUnBalanceDetlQryForm;
import com.hitrust.gs.integration.socket.GSClientSocket;
import com.hitrust.gs.lib.GSBaseConstants;
import com.hitrust.gs.lib.GSLogWriter;
import com.hitrust.gs.lib.GSSystemConfigurator;
import com.hitrust.gs.service.GSBaseForm;
import com.hitrust.gs.service.GSBaseManager;
import com.hitrust.gs.service.GSBaseProcesser;
import com.hitrust.gs.util.DefineDic;
import com.hitrust.gs.util.ParameterFactory;
import com.hitrust.gs.util.date.DateUtil;
import com.hitrust.gs.util.exception.GSException;
import com.hitrust.gs.util.lang.IDGenerator;
import com.hitrust.gs.util.lang.StringUtils;
import com.hitrust.gs.vo.GSBalanceDetailSignModifyVO;
import com.hitrust.gs.vo.GSBalancedDetailQryResultVO;
import com.hitrust.gs.vo.GSBusOrderCancelOfWorkingVO;
import com.hitrust.gs.vo.GSBusOrderCancelVO;
import com.hitrust.gs.vo.GSBusOrderRefundVO;
import com.hitrust.gs.vo.GSDeliverOrderManufactureVO;
import com.hitrust.gs.vo.GSEmergencyOrderDetailVO;
import com.hitrust.gs.vo.GSOrderCancelVO;
import com.hitrust.gs.vo.GSOrderDetailModifyVO;
import com.hitrust.gs.vo.GSOrderDetailOfBusForSWVO;
import com.hitrust.gs.vo.GSOrderDetailOfBusQryVO;
import com.hitrust.gs.vo.GSOrderDetailOfBusVO;
import com.hitrust.gs.vo.GSOrderDetailQueryVO;
import com.hitrust.gs.vo.GSOrderEmergencyOfWorkingVO;
import com.hitrust.gs.vo.GSOrderEmergencyVO;
import com.hitrust.gs.vo.GSOrderMan4QueryVO;
import com.hitrust.gs.vo.GSOrderManufactureVO;
import com.hitrust.gs.vo.GSOrderManufactureVO_;
import com.hitrust.gs.vo.GSOrderQueryDetailExVO;
import com.hitrust.gs.vo.GSOrderQueryDetailVO;
import com.hitrust.gs.vo.GSOrderReceiveQueryVO;
import com.hitrust.gs.vo.GSOrderRefundDetailOfBusVO;
import com.hitrust.gs.vo.GSOrderStatusTraceDetailVO;
import com.hitrust.gs.vo.GSOrderSubmitDetailVO;
import com.hitrust.gs.vo.GSOrderSubmitForNonFlatVO;
import com.hitrust.gs.vo.GSOrderSubmitOfWorkingVO;
import com.hitrust.gs.vo.GSOrderSubmitToApepQueryVO;
import com.hitrust.gs.vo.GSOrderSubmitVO;
import com.hitrust.gs.vo.GSOrderVO;
import com.hitrust.gs.vo.GSUnBalanceDetailQryResultVO;
import com.hitrust.gs.vo.GSUnBalanceDetailQryVO;

public class GSOrderProcessor implements GSBaseProcesser {

	private GSOrderDAO orderDAO = new GSOrderDAO();

	public void orderAudit(String orderCode) throws GSException {

	}

	public GSOrderBean[] query(String sql) throws GSException {

		return null;
	}

	/**
	 * 订单取消
	 * 
	 * @param aGSOperatorBean
	 *            操作员信息
	 * @param aGSOrderBean
	 *            订单基本信息
	 * @throws GSException
	 */
	public void orderCancel(GSOperatorBean aGSOperatorBean, GSOrderBean aGSOrderBean) throws GSException {
		GSOrderDAO tGSOrderDAO = new GSOrderDAO();
		Connection tConn = null;
		try {

			GSOperatorDAO tGSOperatorDAO = new GSOperatorDAO();
			GSOperatorBean tGSOperatorBeanTemp = tGSOperatorDAO.queryOperById(aGSOrderBean.getGs_recorder_id());
			tConn = tGSOrderDAO.getConnetion();
			tConn.setAutoCommit(false);
			boolean tResult = false; // 订单取消是否成功
			// 订单归属判断
			if (tGSOperatorBeanTemp != null && !tGSOperatorBeanTemp.getGs_oper_org_id().substring(0, 2).equals("00")) { // 归属运营
				// 操作员角色判断
				if (tGSOperatorDAO.isRecorder(aGSOperatorBean.getGs_oper_id(), "1") && aGSOperatorBean.getGs_oper_id().equals(aGSOrderBean.getGs_recorder_id())) {// 录入人员
					if (aGSOrderBean.getGs_order_status().equals("1")) { // 订单状态
						// 申请
						tGSOrderDAO.updateOrderStatusToCancel(aGSOrderBean.getGs_order_tempid(), "1", tConn);
						tResult = true;
					} else {
						throw new GSException(GSException.E10046, GSException.E10046_MSG);
					}
				} else {
					throw new GSException(GSException.E10047, GSException.E10047_MSG);
				}
				// else if(aGSOperatorBean.getGs_oper_level().equals("2")
				// && (aGSOrderBean.getGs_order_status().equals("1")
				// ||(aGSOperatorBean.getGs_oper_id().equals(aGSOrderBean.getGs_firstauditor_id())
				// && aGSOrderBean.getGs_order_status().equals("2")))) { //初审人员
				// tGSOrderDAO.updateOrderStatusToCancel(aGSOrderBean.getGs_order_tempid(),aGSOperatorBean.getGs_oper_level(),tConn);
				// tResult = true;
				// } else if(aGSOperatorBean.getGs_oper_level().equals("3")
				// && (aGSOrderBean.getGs_order_status().equals("1")
				// || aGSOrderBean.getGs_order_status().equals("2")
				// ||
				// (aGSOperatorBean.getGs_oper_id().equals(aGSOrderBean.getGs_reviewer_id())
				// && aGSOrderBean.getGs_order_status().equals("3")))) { //复审人员
				// tGSOrderDAO.updateOrderStatusToCancel(aGSOrderBean.getGs_order_tempid(),aGSOperatorBean.getGs_oper_level(),tConn);
				// tResult = true;
				// }
			} else {
				throw new GSException(GSException.E10440, GSException.E10440_MSG);
			}
			if (!tResult) {
				throw new GSException(GSException.E10044, GSException.E10044_MSG);
			} else {
				tConn.commit();
			}
		} catch (SQLException e) {
			try {
				tConn.rollback();
			} catch (SQLException e1) {
				GSLogWriter.error(this, e1.getMessage());
			}
			GSLogWriter.error(this, e.getMessage());
			throw new GSException(GSException.E19994, GSException.E19994_MSG);
		} catch (GSException e) {
			try {
				tConn.rollback();
			} catch (SQLException e1) {
				GSLogWriter.error(this, e1.getMessage());
			}
			GSLogWriter.error(this, e.getMessage());
			throw new GSException(e.getCode(), e.getMessage());
		} catch (Exception e) {
			try {
				tConn.rollback();
			} catch (SQLException e1) {
				GSLogWriter.error(this, e1.getMessage());
			}
			GSLogWriter.error(this, e.getMessage());
			throw new GSException(GSException.E10044, GSException.E10044_MSG);
		} finally {
			GSOrderDAO.close(tConn);
		}

	}

	public void orderModify(GSOrderVO vo) throws GSException {

	}

	public void orderPrint(GSOrderBean[] beans) throws GSException {

	}

	public String saveOrder(LoginContext context, GSOrderVO vo, ArrayList ary,String sign) throws GSException {

		String orderId = orderDAO.insert(context, vo, ary,sign);
		return orderId;
	}


	public void saveMyProduct(LoginContext context, GSOrderVO vo, ArrayList orderDetailList) throws GSException {
		for(int i=0; i<orderDetailList.size(); i++) {
			GSOrderManufactureVO detailVO = (GSOrderManufactureVO)orderDetailList.get(i);
			MyProduct.insertMyProduct(context, vo.orderDeptId, detailVO.manufactureid, detailVO.concentricityId);
		}
	}

	/**
	 * 订单状态修正
	 * 
	 * @param aGSOperatorBean
	 *            操作员信息
	 * @param aGSOrderBean
	 *            订单基本信息
	 * @throws GSException
	 */
	public void orderStatusModify(GSOperatorBean aGSOperatorBean, GSOrderBean aGSOrderBean) throws GSException {
		GSOrderDAO tGSOrderDAO = new GSOrderDAO();
		Connection tConn = null;
		try {

			GSOperatorDAO tGSOperatorDAO = new GSOperatorDAO();
			GSOperatorBean tGSOperatorBeanTemp = tGSOperatorDAO.queryOperById(aGSOrderBean.getGs_recorder_id());
			tConn = tGSOrderDAO.getConnetion();
			tConn.setAutoCommit(false);
			boolean tResult = false; // 订单状态修正是否成功
			// 订单归属判断
			if (tGSOperatorBeanTemp != null && !tGSOperatorBeanTemp.getGs_oper_org_id().substring(0, 2).equals("00")) { // 归属运营
				// 操作员角色判断
				if (aGSOrderBean.getGs_order_status().equals("2")) {
					if (tGSOperatorDAO.isFirstAuditor(aGSOperatorBean.getGs_oper_id(), "1")
							&& aGSOperatorBean.getGs_oper_id().equals(aGSOrderBean.getGs_firstauditor_id()) && aGSOrderBean.getGs_order_status().equals("2")) { // 初审人员
						tGSOrderDAO.updateOrderStatusToBefore(aGSOrderBean.getGs_order_tempid(), "2", "1", tConn);
						tResult = true;
					} else {
						throw new GSException(GSException.E10048, GSException.E10048_MSG);
					}
				} else if (aGSOrderBean.getGs_order_status().equals("3")) {
					if (tGSOperatorDAO.isReviewer(aGSOperatorBean.getGs_oper_id(), "1")
							&& aGSOperatorBean.getGs_oper_id().equals(aGSOrderBean.getGs_reviewer_id()) && aGSOrderBean.getGs_order_status().equals("3")) { // 复审人员
						tGSOrderDAO.updateOrderStatusToBefore(aGSOrderBean.getGs_order_tempid(), "3", "2", tConn);
						tResult = true;
					} else {
						throw new GSException(GSException.E10049, GSException.E10049_MSG);
					}
				}
			} else {
				throw new GSException(GSException.E10441, GSException.E10441_MSG);
			}
			if (!tResult) {
				throw new GSException(GSException.E10045, GSException.E10045_MSG);
			} else {
				tConn.commit();
			}
		} catch (SQLException e) {
			try {
				tConn.rollback();
			} catch (SQLException e1) {
				GSLogWriter.error(this, e1.getMessage());
			}
			GSLogWriter.error(this, e.getMessage());
			throw new GSException(GSException.E19994, GSException.E19994_MSG);
		} catch (GSException e) {
			try {
				tConn.rollback();
			} catch (SQLException e1) {
				GSLogWriter.error(this, e1.getMessage());
			}
			GSLogWriter.error(this, e.getMessage());
			throw new GSException(e.getCode(), e.getMessage());
		} catch (Exception e) {
			try {
				tConn.rollback();
			} catch (SQLException e1) {
				GSLogWriter.error(this, e1.getMessage());
			}
			GSLogWriter.error(this, e.getMessage());
			throw new GSException(GSException.E10045, GSException.E10045_MSG);
		} finally {
			GSOrderDAO.close(tConn);
		}
	}

	public void orderSubmit(String orderCode, String status) throws GSException {

	}

	/**
	 * 从订单编号获得订单Bean
	 * 
	 * @param orderCode
	 *            订单编号
	 * @return
	 * @throws GSException
	 */
	public GSOrderBean selectOrderByCode(String orderCode) throws GSException {

		GSOrderBean tGSOrderBean = new GSOrderBean();

		tGSOrderBean = orderDAO.selectOrderByCode(orderCode);

		return tGSOrderBean;
	}

	/**
	 * 系统为订单创建临时编号
	 * 
	 * @param orgId
	 * @return
	 * @throws GSException
	 */
	public String createOrderId(String orgId) throws GSException {
		// 构造订单号
		IDGenerator idg = new IDGenerator();
		long id = 0;
		try {
			id = idg.generatorID(orgId, "01");
		} catch (Exception e) {
			throw new GSException(GSException.E17777, GSException.E17777_MSG);
		}
		String orderId = orgId + idg.formatID(id, 5);

		return orderId;

	}

	/**
	 * 从产品和操作员查询订单是否需要审核
	 * 
	 * @param auditCategory
	 *            初审/复审
	 * @param operatorId
	 *            操作员id
	 * @param ary
	 *            订单明细bean对象
	 * @return
	 * @throws GSException
	 */
	public boolean isAuditNeed(int auditCategory, String operatorId, ArrayList ary) throws GSException {
		boolean isNeeded = true;
		Connection conn = null;
		try {
			conn = orderDAO.getConnetion();
			String orgType = "";
			// 初审和复审,机构类型为"运营公司"=0
			if (auditCategory == 0 || auditCategory == 1) {
				orgType = "0";
				// 其他情况(审核),机构类型为"巴士物资"=1
			} else {
				orgType = "1";
			}
			String sql = "select count(GS_OPER_ID) from GS_AUDIT_EQUATION_MSG where GS_AUDIT_CATEGORY ='" + auditCategory + "' and GS_OPER_ID = '" + operatorId
			+ "' and gs_org = '" + orgType + "'";
			ResultSet rs = conn.prepareStatement(sql).executeQuery();
			int param1 = 0;
			// 如果操作员在数据表中，则该操作员录入的订单无须审核
			if (rs != null) {
				rs.next();
				param1 = rs.getInt(1);
				rs.close();
				if (param1 > 0) {
					isNeeded = false;
				}
			}
			// else{
			// for(int j=0;j<ary.size();j++){
			//
			// GSOrderDetailBean orderDetailBean =
			// (GSOrderDetailBean)ary.get(j);
			// //根据审核因素，判断是否需要审核订单
			// //审核表中存在该产品的，不需要审核
			// String sqls = "select count(GS_MANUFACTURE_ID) from
			// GS_AUDIT_EQUATION_MSG where GS_AUDIT_CATEGORY
			// ='"+auditCategory+"' and GS_MANUFACTURE_ID = '"+operatorId+"'";
			// ResultSet rss = conn.prepareStatement(sqls).executeQuery();
			// int param2 = 0;
			// if(rss!=null){
			// rss.next();param2 = rs.getInt(1);
			// }
			// rss.close();
			// //如果当前产品需要审核，则整张订单需要审核
			// //不必再循环后面的产品
			// if(param2 = 0){
			// isNeeded = false;
			// break;
			// }
			// }
			// }

		} catch (Exception e) {

		} finally {
			GSOrderDAO.close(conn);
		}

		return isNeeded;
	}

	/*
	 * public boolean isAuditNeed(int auditCategory, String manufactureId,
	 * String operatorId) throws GSException { boolean isNeeded = false;
	 * Connection conn = null; try{ conn = orderDAO.getConnetion(); int value =
	 * -1; if(auditCategory == 0){ value = isFirstAuditNeeded(conn); }else
	 * if(auditCategory == 1 ){ value = this.isSecondAuditNeeded(conn); }
	 * 
	 * String sql = ""; int size = 0; Statement stmt = conn.createStatement();
	 * ResultSet rs = null; //根据审核因素关系表的设置，在审核因素信息表中查询审核条件 switch(value){ case
	 * 0://0表示都不依赖,都不依赖的情况下必须审核 isNeeded = true; break; case 1://1表示只依赖产品 sql =
	 * "select count(*) from gs_audit_equation_msg where gs_audit_category =
	 * '"+auditCategory+"' and gs_manufacture_id == '"+ manufactureId + "'"; rs =
	 * stmt.executeQuery(sql); rs.next(); size = rs.getInt(1); if(size != 0)
	 * isNeeded = true; break; case 2://2表示只依赖操作员 sql = "select count(*) from
	 * gs_audit_equation_msg where gs_audit_category = '"+auditCategory+"' and
	 * gs_operator_id == '"+ manufactureId + "'"; rs = stmt.executeQuery(sql);
	 * rs.next(); size = rs.getInt(1); if(size != 0) isNeeded = true; break;
	 * case 3://3表示都依赖 sql = "select count(*) from gs_audit_equation_msg where
	 * gs_audit_category = '"+auditCategory+"' and gs_operator_id == '"+
	 * operatorId + "' and gs_manufacture_id = '" + manufactureId + "'"; rs =
	 * stmt.executeQuery(sql); rs.next(); size = rs.getInt(1); if(size != 0)
	 * isNeeded = true; break; }
	 * 
	 * rs.close();stmt.close(); return isNeeded;
	 * 
	 * }catch(GSException gse){ throw gse; }catch(Exception e){ throw new
	 * GSException (GSException.BME00001,GSException.BME00001_MSG); }finally{
	 * GSOrderDAO.close(conn); } }
	 */

	/**
	 * 返回审核因素关系表的值(初审)
	 * 
	 * @return
	 * @throws GSException
	 */
	/*
	 * private int isFirstAuditNeeded(Connection conn) throws GSException { int
	 * value = -1; int m=-1;int o=-1; try{
	 * 
	 * String sql_re = "select * from gs_audit_equation_re where
	 * gs_audit_category=0"; Statement stmt = conn.createStatement(); ResultSet
	 * rs = stmt.executeQuery(sql_re); rs.next(); m =
	 * rs.getInt("gs_manufacture_id"); o = rs.getInt("gs_operator_id");
	 * 
	 * }catch(Exception e){throw new
	 * GSException(GSException.BME19999,GSException.BME19999_MSG);}
	 * 
	 * //1表示只依赖产品，2表示只依赖操作员，3表示都依赖，0表示都不依赖 if(m==1 && o == 1) value = 3; if(m ==
	 * 1 && o == 0) value = 1; if(m == 0 && o == 1) value = 2; if(m == 0 && o
	 * ==0) value = 0; return value; }
	 */

	/**
	 * 返回审核因素关系表的值(复审)
	 * 
	 * @return
	 * @throws GSException
	 */
	/*
	 * private int isSecondAuditNeeded(Connection conn) throws GSException { int
	 * value = -1; int m=-1;int o=-1; try{
	 * 
	 * String sql_re = "select * from gs_audit_equation_re where
	 * gs_audit_category=1"; Statement stmt = conn.createStatement(); ResultSet
	 * rs = stmt.executeQuery(sql_re); rs.next(); m =
	 * rs.getInt("gs_manufacture_id"); o = rs.getInt("gs_operator_id");
	 * 
	 * }catch(Exception e){throw new
	 * GSException(GSException.BME19999,GSException.BME19999_MSG);}
	 * 
	 * //1表示只依赖产品，2表示只依赖操作员，3表示都依赖，0表示都不依赖 if(m==1 && o == 1) value = 3; if(m ==
	 * 1 && o == 0) value = 1; if(m == 0 && o == 1) value = 2; if(m == 0 && o
	 * ==0) value = 0; return value; }
	 */

	public void orderManufactureModify(GSOrderManufactureVO[] vos) throws GSException {

	}

	public GSOrganizationBean getOrgByCode(String code) throws GSException {
		return null;
	}

	/**
	 * 取得订单及订单明细（包含订单中产品信息）
	 * 
	 * @param aGSOrderVO
	 *            页面传入参数封装对象
	 * @return
	 * @throws GSException
	 */
	public ArrayList getOrderAndManufacture(GSOrderVO aGSOrderVO) throws GSException {
		ArrayList tOrderList = new ArrayList();
		GSOrderDAO tGSOrderDAO = new GSOrderDAO();
		ArrayList tList = new ArrayList();
		Connection tConn = null;
		try {
			// 取得DB连接
			tConn = tGSOrderDAO.getConnetion();
			// 组装订单Bean对象
			GSOrderBean tOrderBean = new GSOrderBean();
			tOrderBean.setGs_order_tempid(aGSOrderVO.orderid);
			tOrderBean.setGs_order_category(aGSOrderVO.category);
			// 查询所有订单及明细
			// tOrderList = tGSOrderDAO.queryUncommitOrderAndDetail(tConn,
			// aGSOrderVO);
			if (tOrderList.size() > 0) {
				String tOrderId = "";
				GSOrderVO tGSOrderVO = null;
				for (int i = 0; i < tOrderList.size(); i++) {

					GSOrderSubmitVO tGSOrderSubmitVO = (GSOrderSubmitVO) tOrderList.get(i);
					// 判断新取得的OrderSubmitVO对象中的订单编号是否与前一对象中订单编号相同
					if (tOrderId.equals(tGSOrderSubmitVO.orderid)) {
						// 订单编号相同则将取得的产品信息放入同一订单VO对象的ArrayList对象中
						String[] tStr = new String[7];
						tStr[0] = tGSOrderSubmitVO.manufactureId;
						tStr[1] = tGSOrderSubmitVO.manufactureName;
						tStr[2] = StringUtils.formatEDouble(tGSOrderSubmitVO.manufacutreUnitPrice, 2);
						tStr[3] = String.valueOf(tGSOrderSubmitVO.orderCount);
						tStr[4] = StringUtils.formatEDouble(tGSOrderSubmitVO.manufacutreUnitPrice * tGSOrderSubmitVO.orderCount, 2);
						tStr[5] = GSBaseManager.getOrderDeptName(tGSOrderSubmitVO.orderDeptId);
						tStr[6] = GSBaseManager.getProviderName(tGSOrderSubmitVO.providerId);
						tGSOrderVO.tList.add(tStr);
					} else {
						// 订单编号不同创建新的订单VO对象
						tGSOrderVO = new GSOrderVO();
						tGSOrderVO.orderid = tGSOrderSubmitVO.orderid;
						tGSOrderVO.category = GSBaseManager.getOrderCategoryName(tGSOrderSubmitVO.category);
						tGSOrderVO.orderStatus = GSBaseManager.getOrderStatusName(tGSOrderSubmitVO.orderStatus);
						tGSOrderVO.tList = new ArrayList();

						String[] tStr = new String[7];
						tStr[0] = tGSOrderSubmitVO.manufactureId;
						tStr[1] = tGSOrderSubmitVO.manufactureName;
						tStr[2] = StringUtils.formatEDouble(tGSOrderSubmitVO.manufacutreUnitPrice, 2);
						tStr[3] = String.valueOf(tGSOrderSubmitVO.orderCount);
						tStr[4] = StringUtils.formatEDouble(tGSOrderSubmitVO.manufacutreUnitPrice * tGSOrderSubmitVO.orderCount, 2);
						tStr[5] = GSBaseManager.getOrderDeptName(tGSOrderSubmitVO.orderDeptId);
						tStr[6] = GSBaseManager.getProviderName(tGSOrderSubmitVO.providerId);
						tGSOrderVO.tList.add(tStr);
						tOrderId = tGSOrderSubmitVO.orderid;
						// 将订单VO对象放入结果集对象
						tList.add(tGSOrderVO);
					}

				}
			}
		} catch (Exception e) {
			GSLogWriter.debug(this, e.toString());
			throw new GSException(GSException.E10041, GSException.E10041_MSG);
		} finally {
			GSOrderDAO.close(tConn);
		}
		return tList;
	}

	/**
	 * 查询订单中包含的产品信息
	 * 
	 * @param aOrderId
	 *            订单编号
	 * @return
	 * @throws GSException
	 */
	public ArrayList getManufactureByOrderId(String aOrderId) throws GSException {
		ArrayList tList = new ArrayList();
		try {
			GSOrderDetailDAO tGSOrderDetailDAO = new GSOrderDetailDAO();
			// 查询订单明细
			ArrayList tRs = tGSOrderDetailDAO.queryOrderDetail(aOrderId);
			if (tRs.size() > 0) {
				for (int i = 0; i < tRs.size(); i++) {
					String[] tStr = new String[17];
					GSOrderMan4QueryVO tGSOrderMan4QueryVO = (GSOrderMan4QueryVO) tRs.get(i);
					// 取出订单包含的产品信息VO对象组成String数组
					tStr[0] = tGSOrderMan4QueryVO.orderId;
					tStr[1] = tGSOrderMan4QueryVO.manufactureid;
					tStr[2] = tGSOrderMan4QueryVO.manufactureName;
					tStr[3] = StringUtils.formatEDouble(tGSOrderMan4QueryVO.manufactureUnitPrice, 2);
					tStr[4] = tGSOrderMan4QueryVO.ordercount;
					tStr[5] = StringUtils.formatEDouble(tGSOrderMan4QueryVO.manufactureUnitPrice * Integer.parseInt(tGSOrderMan4QueryVO.ordercount), 2);
					tStr[6] = tGSOrderMan4QueryVO.deliverdate;
					tStr[7] = GSBaseManager.getDeliverGoodsTime(tGSOrderMan4QueryVO.delivertime);
					tStr[8] = tGSOrderMan4QueryVO.orderDeptName;
					tStr[9] = tGSOrderMan4QueryVO.deliveraddr;
					tStr[10] = tGSOrderMan4QueryVO.linkman;
					tStr[11] = tGSOrderMan4QueryVO.linktel;
					tStr[12] = tGSOrderMan4QueryVO.delivermode;
					tStr[13] = tGSOrderMan4QueryVO.balancemode;
					tStr[14] = tGSOrderMan4QueryVO.providerName;

					if (!tGSOrderMan4QueryVO.orderDetailStatus.equals("")) {
						tGSOrderMan4QueryVO.orderDetailStatus = GSBaseManager.getOrderDetailStatusName(tGSOrderMan4QueryVO.orderDetailStatus);
					}
					tStr[15] = tGSOrderMan4QueryVO.orderDetailStatus;
					tStr[16] = tGSOrderMan4QueryVO.quantUnit;
					tList.add(tStr);
				}
			}
		} catch (GSException ge) {
			throw ge;
		} catch (Exception e) {
			GSLogWriter.error(this, e.toString());
			throw new GSException(GSException.E10042, GSException.E10042_MSG);
		}
		return tList;
	}

	/**
	 * 录入订单后直接提交
	 * 
	 * @param tList
	 * @param aOperId
	 * @return
	 * @throws GSException
	 */
	public boolean submitOrdersImmediate(ArrayList tList, String aOperId) throws GSException {
		boolean tFlag = false;
		GSOrderDetailDAO tOrderDetailDAO = new GSOrderDetailDAO();
		GSOrderDAO tOrderDAO = new GSOrderDAO();
		Connection tConn = null;
		try {
			if (tList.size() > 0) {
				tConn = tOrderDetailDAO.getConnetion();
				tConn.setAutoCommit(false);
				for (int i = 0; i < tList.size(); i++) {
					GSOrderBean tOrderBean = (GSOrderBean) tList.get(i);
					// 修改订单状态
					GSOrderDetailBean tOrderDetailBean = new GSOrderDetailBean();
					tOrderDetailBean.setGs_order_temp_id(tOrderBean.getGs_order_tempid());
					tOrderDetailBean.setGs_order_detail_status(GSBaseConstants.ORDER_SUBMIT);
					tOrderDetailBean.setGs_lastmodifer_id(aOperId);
					tOrderDetailBean.setGs_lastmodify_contents("执行提交");
					String tCurDT = DateUtil.formateDateTime(DateUtil.getCurrentTime("DT", "AD"));
					tOrderDetailBean.setGs_lastmodify_date(tCurDT);

					tFlag = tOrderDetailDAO.updateDetailStatusByOrderId(tConn, tOrderDetailBean, GSBaseConstants.ORDER_SECONDAUDIT_PASS);
					if (!tFlag) {
						GSLogWriter.debug(this, GSException.E19998_MSG);
						tConn.rollback();
						break;
					}
					tFlag = tOrderDAO.updateOrderStatus(tOrderBean.getGs_order_tempid(), GSBaseConstants.ORDER_SUBMIT, aOperId, tConn);
					if (!tFlag) {
						GSLogWriter.debug(this, GSException.E19998_MSG);
						tConn.rollback();
						break;
					}
				}
				// 全部修改成功后提交
				if (tFlag) {
					tConn.commit();
				}
			}
		} catch (GSException ge) {
			throw ge;
		} catch (Exception e) {
			GSLogWriter.error(this, e.toString());
			throw new GSException(GSException.E10043, GSException.E10043_MSG);
		} finally {
			GSOrderDetailDAO.close(tConn);
		}
		return tFlag;
	}

	/**
	 * 执行提交多笔订单
	 * 
	 * @param tList
	 *            待提交订单对象
	 * @param aOperId
	 *            操作员编号
	 * @throws GSException
	 */
	public boolean submitOrders(ArrayList tList, String aOperId) throws GSException {
		boolean tFlag = false;
		GSOrderDetailDAO tOrderDetailDAO = new GSOrderDetailDAO();
		GSOrderDAO tOrderDAO = new GSOrderDAO();
		Connection tConn = null;
		try {
			if (tList.size() > 0) {
				tConn = tOrderDetailDAO.getConnetion();
				tConn.setAutoCommit(false);
				for (int i = 0; i < tList.size(); i++) {
					GSOrderBean tOrderBean = (GSOrderBean) tList.get(i);
					// 修改订单状态
					GSOrderDetailBean tOrderDetailBean = new GSOrderDetailBean();
					tOrderDetailBean.setGs_order_temp_id(tOrderBean.getGs_order_tempid());
					tOrderDetailBean.setGs_order_detail_status(GSBaseConstants.ORDER_SUBMIT);
					tOrderDetailBean.setGs_lastmodifer_id(aOperId);
					tOrderDetailBean.setGs_lastmodify_contents("执行提交");
					String tCurDT = DateUtil.formateDateTime(DateUtil.getCurrentTime("DT", "AD"));
					tOrderDetailBean.setGs_lastmodify_date(tCurDT);

					tFlag = tOrderDetailDAO.updateDetailStatusByOrderId(tConn, tOrderDetailBean, GSBaseConstants.ORDER_SECONDAUDIT_PASS);
					if (!tFlag) {
						GSLogWriter.debug(this, GSException.E19998_MSG);
						tConn.rollback();
						break;
					}
					tFlag = tOrderDAO.updateOrderStatus(tOrderBean.getGs_order_tempid(), GSBaseConstants.ORDER_SUBMIT, aOperId, tConn);
					if (!tFlag) {
						GSLogWriter.debug(this, GSException.E19998_MSG);
						tConn.rollback();
						break;
					}
				}
				// 全部修改成功后提交
				if (tFlag) {
					tConn.commit();
				}
			}
		} catch (GSException ge) {
			throw ge;
		} catch (Exception e) {
			GSLogWriter.error(this, e.toString());
			throw new GSException(GSException.E10043, GSException.E10043_MSG);
		} finally {
			GSOrderDetailDAO.close(tConn);
		}
		return tFlag;
	}

	/**
	 * 根据不同查询条件取得订单及产品信息
	 * 
	 * @param aOrderVO
	 *            订单VO对象
	 * @return
	 * @throws GSException
	 */
	/*
	 * public ArrayList getOrderByOpt(GSOrderVO aOrderVO,ArrayList aOrgList)
	 * throws GSException{ ArrayList tList = new ArrayList(); //取得查询订单的SQL
	 * String tSql = this.getQueryOrderSql(aOrderVO,aOrgList);
	 * GSLogWriter.debug(this,"SQL=" + tSql); GSOrderDAO tOrderDAO = new
	 * GSOrderDAO(); Connection tConn = null; try{ tConn =
	 * tOrderDAO.getConnetion(); //执行条件查询 ArrayList tRs =
	 * tOrderDAO.queryOrderByOpt(tConn,tSql); if(tRs.size() > 0){ String
	 * tOrderId = ""; GSOrderVO tGSOrderVO = null; for(int i=0; i<tRs.size();
	 * i++){
	 * 
	 * GSOrderQueryVO tGSOrderQueryVO = (GSOrderQueryVO)tRs.get(i);
	 * //判断新取得的OrderSubmitVO对象中的订单编号是否与前一对象中订单编号相同
	 * if(tOrderId.equals(tGSOrderQueryVO.orderid)){
	 * //订单编号相同则将取得的产品信息放入同一订单VO对象的ArrayList对象中 String[] tStr = new String[16];
	 * tStr[0] = tGSOrderQueryVO.manufactureId; tStr[1] =
	 * tGSOrderQueryVO.manufactureName; tStr[2] =
	 * StringUtils.formatEDouble(tGSOrderQueryVO.manufacutreUnitPrice,2);
	 * tStr[3] = String.valueOf(tGSOrderQueryVO.orderCount); tStr[4] =
	 * StringUtils.formatEDouble(tGSOrderQueryVO.manufacutreUnitPrice *
	 * tGSOrderQueryVO.orderCount,2); tStr[5] =
	 * GSBaseManager.getOrderDeptName(tGSOrderQueryVO.orderDeptId); tStr[6] =
	 * GSBaseManager.getProviderName(tGSOrderQueryVO.providerId); tStr[7] =
	 * tGSOrderQueryVO.orderDetailStatus == null? "" :
	 * GSBaseManager.getOrderDetailStatusName(tGSOrderQueryVO.orderDetailStatus);
	 * tStr[8] = tGSOrderQueryVO.quantUnit; tStr[9] =
	 * tGSOrderQueryVO.deliverGoodsDate; tStr[10] =
	 * getDeliverGoodsTimeDesc(tGSOrderQueryVO.deliverGoodsTime); tStr[11] =
	 * tGSOrderQueryVO.deliverGoodsAddr; tStr[12] =
	 * getDeliverModeDesc(tGSOrderQueryVO.deliverMode); tStr[13] =
	 * getBalanceModeDesc(tGSOrderQueryVO.banlanceMode); tStr[14] =
	 * tGSOrderQueryVO.conCentricityId; //新增集中编码字段2006/03/01 tStr[15] =
	 * tGSOrderQueryVO.orderDetailId; tGSOrderVO.tList.add(tStr); }else{
	 * //订单编号不同创建新的订单VO对象 tGSOrderVO = new GSOrderVO(); tGSOrderVO.orderid =
	 * tGSOrderQueryVO.orderid; tGSOrderVO.category =
	 * GSBaseManager.getOrderCategoryName(tGSOrderQueryVO.category);
	 * tGSOrderVO.orderStatus =
	 * GSBaseManager.getOrderStatusName(tGSOrderQueryVO.orderStatus);
	 * tGSOrderVO.tList = new ArrayList();
	 * 
	 * String[] tStr = new String[16]; tStr[0] = tGSOrderQueryVO.manufactureId;
	 * tStr[1] = tGSOrderQueryVO.manufactureName; tStr[2] =
	 * StringUtils.formatEDouble(tGSOrderQueryVO.manufacutreUnitPrice,2);
	 * tStr[3] = String.valueOf(tGSOrderQueryVO.orderCount); tStr[4] =
	 * StringUtils.formatEDouble(tGSOrderQueryVO.manufacutreUnitPrice *
	 * tGSOrderQueryVO.orderCount,2); tStr[5] =
	 * GSBaseManager.getOrderDeptName(tGSOrderQueryVO.orderDeptId); tStr[6] =
	 * GSBaseManager.getProviderName(tGSOrderQueryVO.providerId); tStr[7] =
	 * tGSOrderQueryVO.orderDetailStatus == null? "" :
	 * GSBaseManager.getOrderDetailStatusName(tGSOrderQueryVO.orderDetailStatus.trim());
	 * tStr[8] = tGSOrderQueryVO.quantUnit; tStr[9] =
	 * tGSOrderQueryVO.deliverGoodsDate; tStr[10] =
	 * getDeliverGoodsTimeDesc(tGSOrderQueryVO.deliverGoodsTime); tStr[11] =
	 * tGSOrderQueryVO.deliverGoodsAddr; tStr[12] =
	 * getDeliverModeDesc(tGSOrderQueryVO.deliverMode); tStr[13] =
	 * getBalanceModeDesc(tGSOrderQueryVO.banlanceMode); tStr[14] =
	 * tGSOrderQueryVO.conCentricityId; //新增集中编码字段2006/03/01 tStr[15] =
	 * tGSOrderQueryVO.orderDetailId; tGSOrderVO.tList.add(tStr); tOrderId =
	 * tGSOrderQueryVO.orderid; //将订单VO对象放入结果集对象 tList.add(tGSOrderVO); } } }
	 * }catch(GSException e){ throw e; }catch(Exception e){
	 * GSLogWriter.error(this,e.toString()); throw new
	 * GSException(GSException.BME10041,GSException.BME10041_MSG); }finally{
	 * tOrderDAO.close(); } return tList; }
	 */
	/**
	 * 取得查询SQL
	 * 
	 * @param aOrderVO
	 *            封装页面传入参数的订单VO对象
	 * @return
	 * @throws GSException
	 */
	private String getQueryOrderSql(GSOrderVO aOrderVO, ArrayList aOrgList) throws GSException {
		StringBuffer tSql = new StringBuffer();
		if (aOrderVO != null) {
			tSql.append("select A.GS_ORDER_TEMPID as P1,A.GS_ORDER_CATEGORY as P2,A.GS_ORDER_STATUS as P3");
			tSql.append(",B.GS_MANUFACTURE_ID as P4,C.GS_MANUFACTURE_NAME as P5,C.GS_MANUFACTURE_UNITPRICE as P6,B.GS_ORDER_COUNT as P7,");
			tSql.append("B.GS_ORDER_DEPT_ID as P8 ,B.GS_PROVIDER_ID as P9,B.GS_ORDER_DETAIL_STATUS as P10,C.GS_QUANT_UNIT as P11");
			tSql.append(",B.GS_DELIVER_GOODS_DATE as P12, B.GS_DELIVER_GOODS_TIME as P13, B.GS_DELIVER_GOODS_ADDR as P14");
			tSql.append(",B.GS_DELIVER_MODE as P15, B.GS_BALANCE_MODE as P16,B.GS_CONCENTRICITY_ID as P17,b.GS_ORDER_DETAIL_ID as P18");
			tSql.append(" from GS_ORDER A,GS_ORDER_DETAIL B,GS_MANUFACTURE C,GS_PROVIDER D");
			tSql.append(" where A.GS_ORDER_TEMPID=B.GS_ORDER_TEMPID and B.GS_CONCENTRICITY_ID=C.GS_CONCENTRICITY_ID");
			tSql.append(" and B.GS_MANUFACTURE_ID is NOT NULL and B.GS_MANUFACTURE_ID=C.GS_MANUFACTURE_ID");
			tSql.append(" and B.GS_PROVIDER_ID=D.GS_PROVIDER_ID ");
			tSql.append(" union");
			tSql.append(" select A.GS_ORDER_TEMPID as P1,A.GS_ORDER_CATEGORY as P2,A.GS_ORDER_STATUS as P3");
			tSql.append(",'' as P4,'' as P5,0 as P6,B.GS_ORDER_COUNT as P7,");
			tSql.append("B.GS_ORDER_DEPT_ID as P8 ,B.GS_PROVIDER_ID as P9,B.GS_ORDER_DETAIL_STATUS as P10,C.GS_QUANT_UNIT as P11");
			tSql.append(",B.GS_DELIVER_GOODS_DATE as P12, B.GS_DELIVER_GOODS_TIME as P13, B.GS_DELIVER_GOODS_ADDR as P14");
			tSql.append(",B.GS_DELIVER_MODE as P15, B.GS_BALANCE_MODE as P16,B.GS_CONCENTRICITY_ID as P17,b.GS_ORDER_DETAIL_ID as P18");
			tSql.append(" from GS_ORDER A,GS_ORDER_DETAIL B,GS_MANUFACTURE C,GS_PROVIDER D");
			tSql.append(" where A.GS_ORDER_TEMPID=B.GS_ORDER_TEMPID and B.GS_CONCENTRICITY_ID=C.GS_CONCENTRICITY_ID ");
			tSql.append(" and B.GS_PROVIDER_ID=D.GS_PROVIDER_ID and B.GS_MANUFACTURE_ID is NULL");

			// 判断输入的订单最小值是否为空
			if (aOrderVO.orderIdMin != null && !aOrderVO.orderIdMin.equals("")) {
				tSql.append(" and A.GS_ORDER_TEMPID >='" + aOrderVO.orderIdMin + "'");
			}
			// 判断输入的订单最大值是否为空
			if (aOrderVO.orderIdMax != null && !aOrderVO.orderIdMax.equals("")) {
				tSql.append(" and A.GS_ORDER_TEMPID <='" + aOrderVO.orderIdMax + "'");
			}
			// 判断订单种类是否是全部
			if (!aOrderVO.category.equals("00")) {
				tSql.append(" and A.GS_ORDER_CATEGORY ='" + aOrderVO.category + "'");
			} else {
				tSql.append(" and A.GS_ORDER_CATEGORY like '%'");
			}
			/*
			 * //判断最小产品编码是否为空 if(aOrderVO.manufactureIdMin != null &&
			 * !aOrderVO.manufactureIdMin.equals("")){ tSql.append(" and
			 * B.GS_MANUFACTURE_ID >='"+aOrderVO.manufactureIdMin+"'"); }
			 * //判断最大产品编码是否为空 if(aOrderVO.manufactureIdMax != null &&
			 * !aOrderVO.manufactureIdMax.equals("")){ tSql.append(" and
			 * B.GS_MANUFACTURE_ID <='"+aOrderVO.manufactureIdMax +"'"); }
			 */
			// 判断最小集中编码是否为空
			if (aOrderVO.conCentricityIdMin != null && !aOrderVO.conCentricityIdMin.equals("")) {
				tSql.append(" and B.GS_CONCENTRICITY_ID >='" + aOrderVO.conCentricityIdMin + "'");
			}
			// 判断最大集中编码是否为空
			if (aOrderVO.conCentricityIdMax != null && !aOrderVO.conCentricityIdMax.equals("")) {
				tSql.append(" and B.GS_CONCENTRICITY_ID <='" + aOrderVO.conCentricityIdMax + "'");
			}
			// 判断产品名称是否为空
			if (aOrderVO.manufactureName != null) {
				tSql.append(" and C.GS_MANUFACTURE_NAME like '%" + aOrderVO.manufactureName + "%'");
			}
			// 判断供应商名称是否为空
			if (aOrderVO.providerName != null) {
				tSql.append(" and D.GS_PROVIDER_NAME like '%" + aOrderVO.providerName + "%'");
			}
			if (aOrderVO.orderSumMin > 0) {
				tSql.append(" and A.GS_ORDER_SUM >=" + aOrderVO.orderSumMin);
			}
			if (aOrderVO.orderSumMax > 0) {
				tSql.append(" and A.GS_ORDER_SUM <=" + aOrderVO.orderSumMax);
			}
			// 判断订货单位是否为空

			if (aOrderVO.orderDeptId != null) {
				if (!aOrderVO.orderDeptId.equals("00")) {
					tSql.append(" and B.GS_ORDER_DEPT_ID like '%" + aOrderVO.orderDeptId + "%'");
				} else {
					tSql.append(" and B.GS_ORDER_DEPT_ID in(");
					for (int i = 0; i < aOrgList.size(); i++) {
						GSOrganizationBean tOrgBean = (GSOrganizationBean) aOrgList.get(i);
						if (i == aOrgList.size() - 1) {
							tSql.append(tOrgBean.getGs_org_id() + ")");
						} else {
							tSql.append(tOrgBean.getGs_org_id() + ",");
						}
					}
				}
			}
			// 判断订货状态是否选择为全部
			if (aOrderVO.orderStatus.equals("00")) {
				tSql.append(" and A.GS_ORDER_STATUS like '%'");
			} else {
				tSql.append(" and A.GS_ORDER_STATUS = '" + aOrderVO.orderStatus + "'");
			}
			if (aOrderVO.orderDetailStatus.equals("00")) {
				tSql.append(" and (B.GS_ORDER_DETAIL_STATUS like '%' or B.GS_ORDER_DETAIL_STATUS is NULL)");
			} else {
				tSql.append(" and B.GS_ORDER_DETAIL_STATUS = '" + aOrderVO.orderDetailStatus + "'");
			}
			// tSql.append(" order by A.GS_ORDER_TEMPID");
		} else {
			GSLogWriter.debug(this, "传入参数订单VO对象为空");
			throw new GSException(GSException.E00002, GSException.E00002_MSG);
		}
		return tSql.toString();

	}

	/**
	 * 取得所有已核准的订单明细信息
	 * 
	 * @param aOrderSubmitToApepVO
	 *            参数VO
	 * @param aOrg
	 *            可操作订货单位对象
	 * @return
	 * @throws GSException
	 */
	public ArrayList getOrderAndOrderDetail(GSOrderSubmitToApepQueryVO aOrderSubmitToApepVO, int pageNo, int pageSize) throws GSException {
		ArrayList tRs = new ArrayList();
		GSOrderDetailDAO tGSOrderDetailDAO = new GSOrderDetailDAO();
		// 查询已核准网上订单明细
		ArrayList tList = tGSOrderDetailDAO.queryAllAuthoriseOrders(aOrderSubmitToApepVO, pageNo, pageSize);
		if (tList.size() > 0) {
			double totalAmt = 0;
			// 重新组合查询列值
			for (int i = 0; i < tList.size(); i++) {
				GSOrderSubmitToApepQueryVO tOrderManufVO = (GSOrderSubmitToApepQueryVO) tList.get(i);
				String[] tStr = new String[21];
				tStr[0] = tOrderManufVO.orderDetailId;
				tStr[1] = tOrderManufVO.concentricityId;
				tStr[2] = tOrderManufVO.manufName;
				tStr[3] = tOrderManufVO.isTradeFlatManuf;
				tStr[4] = tOrderManufVO.manufSpec;
				tStr[5] = tOrderManufVO.manufType;
				tStr[6] = tOrderManufVO.manufBrand;
				tStr[7] = tOrderManufVO.providerName;
				tStr[8] = StringUtils.formatEDouble(tOrderManufVO.orderCount, 2);
				tStr[9] = tOrderManufVO.quantUnit;
				tStr[10] = StringUtils.formatEDouble(tOrderManufVO.goodsUnitprice, 4);
				double temp = tOrderManufVO.goodsUnitprice * tOrderManufVO.orderCount;
				tStr[11] = StringUtils.formatEDouble(temp, 4);
				totalAmt = totalAmt + temp;
				tStr[12] = tOrderManufVO.orderDeptName;
				tStr[13] = tOrderManufVO.deliverGoodsDate;
				tStr[14] = GSBaseManager.getDeliverGoodsTime(tOrderManufVO.deliverGoodsTime);
				tStr[15] = tOrderManufVO.orderId;
				tStr[16] = tOrderManufVO.providerId;
				tStr[17] = tOrderManufVO.isTradeFlatProvider;
				tStr[18] = tOrderManufVO.mode;
				tStr[19] = tOrderManufVO.is_normal;
				tStr[20] = tOrderManufVO.drawingpiececode;
				tRs.add(tStr);
			}
			tRs.add(tList.size(), StringUtils.formatEDouble(totalAmt, 2));
		}
		return tRs;
	}

	/**
	 * 提交订单明细到采购网_逐一提交
	 * 
	 * @param aOrderDetailId
	 *            订单明细编码
	 * @param aOperId
	 *            操作员编码
	 * @return
	 * @throws GSException
	 */
	public String submitOrderDetailToApep(String[] aOrderDetailId, LoginContext aOperBean) throws GSException {
		String tRs = "";
		Connection tConn = null;
		GSOrderDetailDAO tOrderDetailDAO = new GSOrderDetailDAO();
		boolean tFlag = false;
		ArrayList tList = new ArrayList();
		int err = 0;// 提交失败记录数
		int ok = 0;// 提交成功记录数
		String returnmsg = "";// 返回消息
		try {
			// 读取采购网给巴士物资的编码
			String tPurCode = GSSystemConfigurator.getParam("gs.purcode");
			// 读取系统工作日
			// String tWorkDT =
			// GSSystemConfigurator.getParam("gs.workdatetime");
			String tWorkDT = DateUtil.formateDateTime(DateUtil.getCurrentTime("DT", "AD"));

			StringBuffer tContent = new StringBuffer();
			tConn = tOrderDetailDAO.getConnetion();
			tConn.setAutoCommit(false);
			if (aOrderDetailId.length > 0) {
				BigDecimal tTotal = new BigDecimal("0");
				String tOrderDetailId[] = new String[aOrderDetailId.length];

				GSOrderDAO orddao = new GSOrderDAO();
				String purName = "";
				ParameterFactory pf = new ParameterFactory();
				for (int i = 0; i < aOrderDetailId.length; i++) {
					String temp = aOrderDetailId[i];
					tOrderDetailId[i] = temp.substring(0, temp.indexOf("-"));
					GSOrderManufactureVO tOrderManufVO = tOrderDetailDAO.queryOrderDetailById(tConn, tOrderDetailId[i]);
					tList.add(tOrderManufVO);
					String count = temp.substring(temp.indexOf("-") + 1).trim();
					tTotal = tTotal.add(new BigDecimal(count));
					// 创建订单明细bean对象，设定待修改数据
					GSOrderDetailBean tOrderDetailBean = new GSOrderDetailBean();
					tOrderDetailBean.setGs_order_detail_id(tOrderDetailId[i]);
					tOrderDetailBean.setGs_order_detail_status(GSBaseConstants.ORDER_ORDERING);
					tOrderDetailBean.setGs_lastmodifer_id(aOperBean.getLoginUserId());
					String tCurDT = DateUtil.getCurrentTime("DT", "AD");
					tCurDT = DateUtil.formateDateTime(DateUtil.getCurrentTime("DT", "AD"));
					tOrderDetailBean.setGs_lastmodify_date(tCurDT);
					tOrderDetailBean.setGs_submiter_id2(aOperBean.getLoginUserId());
					tOrderDetailBean.setGs_submit_date2(tCurDT);
					// 修改订单明细状态为订货中
					tFlag = tOrderDetailDAO.updateOrderDetailStatus(tOrderDetailBean, tConn, GSBaseConstants.ORDER_AUTHORISE);

					if (tFlag) {
						// continue;
						// 组装要发送到采购网的内容
						if (tOrderManufVO != null) {
							purName = orddao.getWorkCorp(tOrderManufVO.orderId);
							pf.clear();
							pf.addParam("Action", "CreateOrder");
							pf.addParam("Count", "1");
							pf.addParam("Total", "1");// count

							pf.addParam("CusOrderItemCode_0", tOrderManufVO.orderDetailId);
							pf.addParam("ProductID_0", tOrderManufVO.manufactureid);
							pf.addParam("CusItemCode_0", tOrderManufVO.concentricityId);
							pf.addParam("Price_0", String.valueOf(tOrderManufVO.manufactureUnitPrice));
							pf.addParam("Qty_0", tOrderManufVO.ordercount);
							pf.addParam("SendMode_0", GSBaseManager.getDictioanryName(tOrderManufVO.delivermode));
							pf.addParam("PayMode_0", GSBaseManager.getDictioanryName(tOrderManufVO.balancemode));
							pf.addParam("SendRequire_0", (tOrderManufVO.deliverdate == null ? "" : tOrderManufVO.deliverdate) + " "
									+ (tOrderManufVO.delivertime == null ? "" : GSBaseManager.getDeliverGoodsTime(tOrderManufVO.delivertime)));
							pf.addParam("Address_0", tOrderManufVO.deliveraddr);
							pf.addParam("LinkPerson_0", (tOrderManufVO.linkman == null ? "" : tOrderManufVO.linkman));
							pf.addParam("LinkPhone_0", (tOrderManufVO.linktel == null ? "" : tOrderManufVO.linktel));
							pf.addParam("CusCode_0", tPurCode);
							pf.addParam("PurName_0", purName);
							pf.addParam("Remark_0", (tOrderManufVO.orderDetailNote == null ? "" : tOrderManufVO.orderDetailNote));
							pf.addParam("CreateTime_0", tWorkDT);
							pf.addParam("SubmitPerson_0", aOperBean.getLoginUserName());
							// http方式
							// 连接服务端
							String tHttp = GSSystemConfigurator.getParam("gs.HttpServletUrl");
							GSClientSocket tClientHttp = new GSClientSocket(tHttp);
							// 发送订单信息到采购网
							tRs = tClientHttp.sendContents(pf.getStrStream());
							// 判断返回结果
							if (tRs.equals("1")) {
								tConn.commit();
								ok++;
								GSLogWriter.debug(this, "提交返回成功");
								// tOrderDetailDAO.updateORDERRETURNSIGN(tOrderDetailId[i],
								// GSBaseConstants.APEP_RETURN_SIGN_OK);
							} else {
								tConn.rollback();
								err++;
								GSLogWriter.error(this, "提交返回失败");
								// 更新订单提交返回状态
								// tOrderDetailDAO.updateORDERRETURNSIGN(tOrderDetailId[i],
								// GSBaseConstants.APEP_RETURN_SIGN_FAIL);
							}

						} else {
							GSLogWriter.error(this, "根据订单明细ID未查询到订单明细");
							throw new GSException(GSException.E10041, GSException.E10041_MSG);
						}
					} else {
						GSLogWriter.error(this, "修改订单明细状态失败");
						tConn.rollback();
						throw new GSException(GSException.E10051, GSException.E10051_MSG);
					}
				}
				if (err == 0) {
					returnmsg = "有" + ok + "笔订单提交成功";
				} else if (err > 0) {
					returnmsg = "有" + ok + "笔订单提交成功,有" + err + "笔订单APEP无法提供网上处理,您可以在手动订单处理功能中进行打印处理。";
				}
			} else {
				GSLogWriter.error(this, "传入的参数－订单明细ID为空");
				throw new GSException(GSException.E00003, GSException.E00003_MSG);
			}
		} catch (GSException ge) {
			try {
				if (tConn != null) {
					tConn.rollback();
				}
			} catch (SQLException se) {
				GSLogWriter.error(this, se.toString());
				throw new GSException(GSException.E19994, GSException.E19994_MSG);
			}
			throw ge;
		} catch (Exception e) {
			try {
				if (tConn != null) {
					tConn.rollback();
				}
			} catch (SQLException se) {
				GSLogWriter.error(this, se.toString());
				throw new GSException(GSException.E19994, GSException.E19994_MSG);
			}
			throw new GSException(GSException.E00001, GSException.E00001_MSG);
		} finally {
			GSOrderDetailDAO.close(tConn);
		}
		return returnmsg;
	}

	/**
	 * 提交订单明细到采购网_old
	 * 
	 * @param aOrderDetailId
	 *            订单明细编码
	 * @param aOperId
	 *            操作员编码
	 * @return
	 * @throws GSException
	 */
	public String submitOrderDetailToApepOld(String[] aOrderDetailId, GSOperatorBean aOperBean) throws GSException {
		String tRs = "";
		Connection tConn = null;
		GSOrderDetailDAO tOrderDetailDAO = new GSOrderDetailDAO();
		boolean tFlag = false;
		ArrayList tList = new ArrayList();
		ArrayList tReturnList = new ArrayList();
		try {
			// 读取采购网给巴士物资的编码
			String tPurCode = GSSystemConfigurator.getParam("gs.purcode");
			// 读取系统工作日
			// String tWorkDT =
			// GSSystemConfigurator.getParam("gs.workdatetime");
			String tWorkDT = DateUtil.formateDateTime(DateUtil.getCurrentTime("DT", "AD"));

			StringBuffer tContent = new StringBuffer();
			tConn = tOrderDetailDAO.getConnetion();
			tConn.setAutoCommit(false);
			if (aOrderDetailId.length > 0) {
				BigDecimal tTotal = new BigDecimal("0");
				String tOrderDetailId[] = new String[aOrderDetailId.length];
				for (int i = 0; i < aOrderDetailId.length; i++) {
					String temp = aOrderDetailId[i];
					tOrderDetailId[i] = temp.substring(0, temp.indexOf("-"));
					GSOrderManufactureVO tOrderManufVO = tOrderDetailDAO.queryOrderDetailById(tConn, tOrderDetailId[i]);
					tList.add(tOrderManufVO);
					String count = temp.substring(temp.indexOf("-") + 1).trim();
					tTotal = tTotal.add(new BigDecimal(count));
					// 创建订单明细bean对象，设定待修改数据
					GSOrderDetailBean tOrderDetailBean = new GSOrderDetailBean();
					tOrderDetailBean.setGs_order_detail_id(tOrderDetailId[i]);
					tOrderDetailBean.setGs_order_detail_status(GSBaseConstants.ORDER_ORDERING);
					tOrderDetailBean.setGs_lastmodifer_id(aOperBean.getGs_oper_id());
					String tCurDT = DateUtil.getCurrentTime("DT", "AD");
					tCurDT = DateUtil.formateDateTime(DateUtil.getCurrentTime("DT", "AD"));
					tOrderDetailBean.setGs_lastmodify_date(tCurDT);
					tOrderDetailBean.setGs_submiter_id2(aOperBean.getGs_oper_id());
					tOrderDetailBean.setGs_submit_date2(tCurDT);
					// 修改订单明细状态为订货中
					tFlag = tOrderDetailDAO.updateOrderDetailStatus(tOrderDetailBean, tConn, GSBaseConstants.ORDER_AUTHORISE);
					if (tFlag) {
						continue;
					} else {
						GSLogWriter.error(this, "修改订单明细状态失败");
						tConn.rollback();
						throw new GSException(GSException.E10051, GSException.E10051_MSG);
					}
				}
				// 组装要发送到采购网的内容
				ParameterFactory pf = new ParameterFactory();
				pf.addParam("Action", "CreateOrder");
				pf.addParam("Count", String.valueOf(aOrderDetailId.length));
				pf.addParam("Total", tTotal.toString());

				// tContent.append("Action=CreateOrder&Count=" +
				// aOrderDetailId.length);
				// tContent.append("&Total=" + tTotal.toString());
				GSOrderDAO orddao = new GSOrderDAO();
				String purName = "";
				for (int i = 0; i < tList.size(); i++) {
					GSOrderManufactureVO tOrderManufVO = (GSOrderManufactureVO) tList.get(i);
					if (tOrderManufVO != null) {
						// tOrderIds[i] = tOrderManufVO.orderId ;
						purName = orddao.getWorkCorp(tOrderManufVO.orderId);
						/*
						 * tContent.append("&CusOrderItemCode_" + i + "=" +
						 * tOrderManufVO.orderDetailId);
						 * tContent.append("&ProductID_" + i + "=" +
						 * tOrderManufVO.manufactureid); // 产品编码
						 * tContent.append("&CusItemCode_" + i + "=" +
						 * tOrderManufVO.concentricityId);// 集中编号
						 * tContent.append("&Price_" + i + "=" +
						 * tOrderManufVO.manufactureUnitPrice);
						 * tContent.append("&Qty_" + i + "=" +
						 * tOrderManufVO.ordercount);
						 * tContent.append("&SendMode_" + i + "=" +
						 * tOrderManufVO.delivermode);
						 * tContent.append("&PayMode_" + i + "=" +
						 * tOrderManufVO.balancemode);
						 * tContent.append("&SendRequire_" + i + "="); //送货日期时间
						 * 
						 * tContent.append((tOrderManufVO.deliverdate == null ? "" :
						 * tOrderManufVO.deliverdate) + " " +
						 * (tOrderManufVO.delivertime == null ? "" :
						 * GSBaseManager
						 * .getDeliverGoodsTime(tOrderManufVO.delivertime)));
						 * tContent.append("&Address_" + i + "=" +
						 * tOrderManufVO.deliveraddr);
						 * tContent.append("&LinkPerson_" + i + "=" +
						 * (tOrderManufVO.linkman == null ? "" :
						 * tOrderManufVO.linkman));
						 * tContent.append("&LinkPhone_" + i + "=" +
						 * (tOrderManufVO.linktel == null ? "" :
						 * tOrderManufVO.linktel)); tContent.append("&CusCode_" +
						 * i + "=" + tPurCode); tContent.append("&PurName_" + i +
						 * "=" + purName);// 订货单位编号 tContent.append("&Remark_" +
						 * i + "=" + (tOrderManufVO.orderDetailNote == null ? "" :
						 * tOrderManufVO.orderDetailNote)); // String
						 * tCreateTime = //
						 * DateUtil.formateDateTime(DateUtil.getCurrentTime("DT","AD"));
						 * tContent.append("&CreateTime_" + i + "=" + tWorkDT);
						 * 
						 * tContent.append("&SubmitPerson_" + i + "=" +
						 * aOperBean.getGs_oper_name()); if (i ==
						 * tOrderDetailId.length - 1) tContent.append("&");
						 */
						pf.addParam("CusOrderItemCode_" + i, tOrderManufVO.orderDetailId);
						pf.addParam("ProductID_" + i, tOrderManufVO.manufactureid);
						pf.addParam("CusItemCode_" + i, tOrderManufVO.concentricityId);
						pf.addParam("Price_" + i, String.valueOf(tOrderManufVO.manufactureUnitPrice));
						pf.addParam("Qty_" + i, tOrderManufVO.ordercount);
						pf.addParam("SendMode_" + i, GSBaseManager.getDictioanryName(tOrderManufVO.delivermode));
						pf.addParam("PayMode_" + i, GSBaseManager.getDictioanryName(tOrderManufVO.balancemode));
						pf.addParam("SendRequire_" + i, (tOrderManufVO.deliverdate == null ? "" : tOrderManufVO.deliverdate) + " "
								+ (tOrderManufVO.delivertime == null ? "" : GSBaseManager.getDeliverGoodsTime(tOrderManufVO.delivertime)));
						pf.addParam("Address_" + i, tOrderManufVO.deliveraddr);
						pf.addParam("LinkPerson_" + i, (tOrderManufVO.linkman == null ? "" : tOrderManufVO.linkman));
						pf.addParam("LinkPhone_" + i, (tOrderManufVO.linktel == null ? "" : tOrderManufVO.linktel));
						pf.addParam("CusCode_" + i, tPurCode);
						pf.addParam("PurName_" + i, purName);
						pf.addParam("Remark_" + i, (tOrderManufVO.orderDetailNote == null ? "" : tOrderManufVO.orderDetailNote));
						pf.addParam("CreateTime_" + i, tWorkDT);
						pf.addParam("SubmitPerson_" + i, aOperBean.getGs_oper_name());
						tReturnList.add(tOrderManufVO.orderDetailId);
					} else {
						GSLogWriter.error(this, "根据订单明细ID未查询到订单明细");
						throw new GSException(GSException.E10041, GSException.E10041_MSG);
					}
				}
				// GSLogWriter.debug(this, "传送内容" + tContent.toString());
				GSLogWriter.debug(this, "传送内容" + pf.getStrStream());
				// 取得配置文件中服务端IP和端口参数
				String tIP = GSSystemConfigurator.getParam("gs.ip");
				String tPort = GSSystemConfigurator.getParam("gs.port");
				// 连接服务端
				GSClientSocket tClientSocket = new GSClientSocket(tIP, Integer.parseInt(tPort));

				// 发送订单信息到采购网
				tRs = tClientSocket.sendContents(pf.getStrStream());
				// tRs = "1";
				// 判断返回结果
				if (tRs.equals("1")) {
					tConn.commit();
					GSLogWriter.debug(this, "提交返回成功");
				} else {
					tConn.rollback();
					GSLogWriter.error(this, "提交返回失败");
				}
			} else {
				GSLogWriter.error(this, "传入的参数－订单明细ID为空");
				throw new GSException(GSException.E00003, GSException.E00003_MSG);
			}
		} catch (GSException ge) {
			try {
				if (tConn != null) {
					tConn.rollback();
				}
			} catch (SQLException se) {
				GSLogWriter.error(this, se.toString());
				throw new GSException(GSException.E19994, GSException.E19994_MSG);
			}
			throw ge;
		} catch (Exception e) {
			try {
				if (tConn != null) {
					tConn.rollback();
				}
			} catch (SQLException se) {
				GSLogWriter.error(this, se.toString());
				throw new GSException(GSException.E19994, GSException.E19994_MSG);
			}
			throw new GSException(GSException.E00001, GSException.E00001_MSG);
		} finally {
			GSOrderDetailDAO.close(tConn);
		}
		return tRs;
	}

	/**
	 * 查询一个订单的所有明细，用于订单录入
	 * 
	 * @param orderId
	 * @return
	 * @throws GSException
	 */
	public ArrayList getOrderDetail_(String orderId) throws GSException {
		ArrayList tList = new ArrayList();
		try {
			GSOrderDetailDAO tGSOrderDetailDAO = new GSOrderDetailDAO();
			// 查询订单明细
			ArrayList tRs = tGSOrderDetailDAO.queryOrderDetail_(orderId);
			if (tRs.size() > 0) {
				for (int i = 0; i < tRs.size(); i++) {
					String[] tStr = new String[26];
					GSOrderManufactureVO_ tGSOrderManufactureVO = (GSOrderManufactureVO_) tRs.get(i);
					// 取出订单包含的产品信息VO对象组成String数组
					tStr[0] = tGSOrderManufactureVO.orderTempId;
					tStr[1] = tGSOrderManufactureVO.orderDetailId;
					tStr[2] = tGSOrderManufactureVO.manufactureId;
					tStr[3] = tGSOrderManufactureVO.manufactureName;
					tStr[4] = tGSOrderManufactureVO.contentricityId;
					tStr[5] = tGSOrderManufactureVO.orderCount;
					tStr[6] = tGSOrderManufactureVO.deliverGoodsDate;
					tStr[7] = GSBaseManager.getDeliverGoodsTime(tGSOrderManufactureVO.deliverGoodsTime);
					tStr[8] = tGSOrderManufactureVO.manufactureSpec == null ? "" : tGSOrderManufactureVO.manufactureSpec;
					tStr[9] = tGSOrderManufactureVO.manufactureType == null ? "" : tGSOrderManufactureVO.manufactureType;
					tStr[10] = tGSOrderManufactureVO.manufactrueBrand == null ? "" : tGSOrderManufactureVO.manufactrueBrand;
					tStr[11] = tGSOrderManufactureVO.quantUnit == null ? "" : tGSOrderManufactureVO.quantUnit;
					tStr[12] = tGSOrderManufactureVO.authorizeAdvices == null ? "" : tGSOrderManufactureVO.authorizeAdvices;
					tStr[13] = tGSOrderManufactureVO.rejectCause == null ? "" : tGSOrderManufactureVO.rejectCause;
					tStr[14] = StringUtils.formatEDouble(tGSOrderManufactureVO.goodunitprice, 4);
					tStr[15] = tGSOrderManufactureVO.period == null ? "" : tGSOrderManufactureVO.period;
					BigDecimal tempDouble = new BigDecimal(tGSOrderManufactureVO.goodunitprice).multiply(new BigDecimal(tGSOrderManufactureVO.orderCount));
					tStr[16] = StringUtils.formatEDouble(tempDouble.doubleValue(), 4);// total
					// price
					tStr[17] = tGSOrderManufactureVO.providerId;
					tStr[18] = tGSOrderManufactureVO.providerName;
					tStr[19] = tGSOrderManufactureVO.isTradeFlatManu;
					tStr[20] = tGSOrderManufactureVO.isTradeFlatProv;
					tStr[21] = GSBaseManager.getOrderDetailStatusName(tGSOrderManufactureVO.detailStatus.trim());
					tStr[22] = tGSOrderManufactureVO.balanceCategory;
					tStr[23] = tGSOrderManufactureVO.deliverGoodsTime;
					tStr[24] = tGSOrderManufactureVO.mode;
					tStr[25] = DefineDic.getBalanceMode(tGSOrderManufactureVO.mode);
					tList.add(tStr);
				}
			}
		} catch (GSException ge) {
			throw ge;
		} catch (Exception e) {
			GSLogWriter.error(this, e.toString());
			throw new GSException(GSException.E10042, GSException.E10042_MSG);
		}
		return tList;
	}

	public ArrayList queryOrderDetailWithStausReconfirm(String orderId) throws GSException {
		ArrayList tList = new ArrayList();
		try {
			GSOrderDetailDAO tGSOrderDetailDAO = new GSOrderDetailDAO();
			// 查询订单明细
			ArrayList tRs = tGSOrderDetailDAO.queryOrderDetailWithStausReconfirm(orderId);
			if (tRs.size() > 0) {
				for (int i = 0; i < tRs.size(); i++) {
					String[] tStr = new String[24];
					GSOrderManufactureVO_ tGSOrderManufactureVO = (GSOrderManufactureVO_) tRs.get(i);
					// 取出订单包含的产品信息VO对象组成String数组
					tStr[0] = tGSOrderManufactureVO.orderTempId;
					tStr[1] = tGSOrderManufactureVO.orderDetailId;
					tStr[2] = tGSOrderManufactureVO.manufactureId;
					tStr[3] = tGSOrderManufactureVO.manufactureName;
					tStr[4] = tGSOrderManufactureVO.contentricityId;
					tStr[5] = tGSOrderManufactureVO.orderCount;
					tStr[6] = tGSOrderManufactureVO.deliverGoodsDate;
					tStr[7] = GSBaseManager.getDeliverGoodsTime(tGSOrderManufactureVO.deliverGoodsTime);
					tStr[8] = tGSOrderManufactureVO.manufactureSpec == null ? "" : tGSOrderManufactureVO.manufactureSpec;
					tStr[9] = tGSOrderManufactureVO.manufactureType == null ? "" : tGSOrderManufactureVO.manufactureType;
					tStr[10] = tGSOrderManufactureVO.manufactrueBrand == null ? "" : tGSOrderManufactureVO.manufactrueBrand;
					tStr[11] = tGSOrderManufactureVO.quantUnit == null ? "" : tGSOrderManufactureVO.quantUnit;
					tStr[12] = tGSOrderManufactureVO.authorizeAdvices == null ? "" : tGSOrderManufactureVO.authorizeAdvices;
					tStr[13] = tGSOrderManufactureVO.rejectCause == null ? "" : tGSOrderManufactureVO.rejectCause;
					tStr[14] = StringUtils.formatEDouble(tGSOrderManufactureVO.goodunitprice, 4);
					tStr[15] = tGSOrderManufactureVO.period == null ? "" : tGSOrderManufactureVO.period;
					BigDecimal tempDouble = new BigDecimal(tGSOrderManufactureVO.goodunitprice).multiply(new BigDecimal(tGSOrderManufactureVO.orderCount));
					tStr[16] = StringUtils.formatEDouble(tempDouble.doubleValue(), 4);// total
					// price
					tStr[17] = tGSOrderManufactureVO.providerId;
					tStr[18] = tGSOrderManufactureVO.providerName;
					tStr[19] = tGSOrderManufactureVO.isTradeFlatManu;
					tStr[20] = tGSOrderManufactureVO.isTradeFlatProv;
					tStr[21] = GSBaseManager.getOrderDetailStatusName(tGSOrderManufactureVO.detailStatus.trim());
					tStr[22] = tGSOrderManufactureVO.balanceCategory;
					tStr[23] = tGSOrderManufactureVO.deliverGoodsTime;

					tList.add(tStr);
				}
			}
		} catch (GSException ge) {
			throw ge;
		} catch (Exception e) {
			GSLogWriter.error(this, e.toString());
			throw new GSException(GSException.E10042, GSException.E10042_MSG);
		}
		return tList;
	}

	/**
	 * 查询一个订单的所有明细，用于送货单录入
	 * 
	 * @param orderId
	 * @return
	 * @throws GSException
	 */
	public ArrayList getDeliverOrderDetail(String orderId) throws GSException {
		ArrayList tList = new ArrayList();
		try {
			GSOrderDetailDAO tGSOrderDetailDAO = new GSOrderDetailDAO();
			// 查询订单明细
			ArrayList tRs = tGSOrderDetailDAO.queryDeliverOrderDetail(orderId);
			if (tRs.size() > 0) {
				for (int i = 0; i < tRs.size(); i++) {
					String[] tStr = new String[18];
					GSDeliverOrderManufactureVO tGSOrderManufactureVO = (GSDeliverOrderManufactureVO) tRs.get(i);
					// 取出订单包含的产品信息VO对象组成String数组
					tStr[0] = tGSOrderManufactureVO.orderTempId;
					tStr[1] = tGSOrderManufactureVO.orderDetailId;
					tStr[2] = tGSOrderManufactureVO.manufactureName;
					tStr[3] = tGSOrderManufactureVO.contentricityId;
					tStr[4] = tGSOrderManufactureVO.orderCount;
					tStr[5] = tGSOrderManufactureVO.manufactureSpec == null ? "" : tGSOrderManufactureVO.manufactureSpec;
					tStr[6] = tGSOrderManufactureVO.manufactureType == null ? "" : tGSOrderManufactureVO.manufactureType;
					tStr[7] = tGSOrderManufactureVO.manufactrueBrand == null ? "" : tGSOrderManufactureVO.manufactrueBrand;
					tStr[8] = tGSOrderManufactureVO.quantUnit == null ? "" : tGSOrderManufactureVO.quantUnit;
					tStr[9] = StringUtils.formatEDouble(tGSOrderManufactureVO.goodunitprice, 4);
					BigDecimal tempDouble = new BigDecimal(tGSOrderManufactureVO.unitPrice).multiply(new BigDecimal(tGSOrderManufactureVO.orderCount));
					tStr[10] = StringUtils.formatEDouble(tempDouble.doubleValue(), 4);// total
					// price
					tStr[11] = tGSOrderManufactureVO.providerId;
					tStr[12] = tGSOrderManufactureVO.providerName;
					tStr[13] = GSBaseManager.getOrderDetailStatusName(tGSOrderManufactureVO.detailStatus.trim());
					tStr[14] = tGSOrderManufactureVO.deliverGoodsId;
					tStr[15] = tGSOrderManufactureVO.manufacturerName;
					tStr[16] = tGSOrderManufactureVO.signinDate;
					tStr[17] = tGSOrderManufactureVO.signinPerson;
					tList.add(tStr);
				}
			}
		} catch (GSException ge) {
			throw ge;
		} catch (Exception e) {
			GSLogWriter.error(this, e.toString());
			throw new GSException(GSException.E10042, GSException.E10042_MSG);
		}
		return tList;

	}

	/**
	 * 查询一个订单的所有明细，用于订单录入
	 * 
	 * @param orderId
	 * @return
	 * @throws GSException
	 */
	public ArrayList getOrderDetail(String orderId) throws GSException {
		ArrayList tList = new ArrayList();
		try {
			GSOrderDetailDAO tGSOrderDetailDAO = new GSOrderDetailDAO();
			// 查询订单明细
			ArrayList tRs = tGSOrderDetailDAO.queryOrderDetail_(orderId);
			if (tRs.size() > 0) {
				for (int i = 0; i < tRs.size(); i++) {
					String[] tStr = new String[19];
					GSOrderQueryDetailVO tGSOrderManufactureVO = (GSOrderQueryDetailVO) tRs.get(i);
					// 取出订单包含的产品信息VO对象组成String数组
					tStr[0] = tGSOrderManufactureVO.orderDetailId;
					tStr[1] = tGSOrderManufactureVO.concentricityId;
					tStr[2] = tGSOrderManufactureVO.manufactureName;
					tStr[3] = tGSOrderManufactureVO.manufSpec;
					tStr[4] = tGSOrderManufactureVO.manufType;
					tStr[5] = tGSOrderManufactureVO.manufBrand;
					tStr[6] = tGSOrderManufactureVO.ordercount + tGSOrderManufactureVO.quantUnit;
					if (tGSOrderManufactureVO.orderDetailStatus.equals(GSBaseConstants.ORDER_DELIVERY_CONFIRM)
							|| tGSOrderManufactureVO.orderDetailStatus.equals(GSBaseConstants.ORDER_ORDER_CONFIRM)) {
						tStr[7] = StringUtils.formatEDouble(tGSOrderManufactureVO.goodsUnitprice, 2);
						tStr[8] = StringUtils.formatEDouble(tGSOrderManufactureVO.goodsUnitprice * tGSOrderManufactureVO.ordercount, 2);
					} else {
						tStr[7] = "";
						tStr[8] = "";
					}
					tStr[9] = tGSOrderManufactureVO.deliverdate;
					tStr[10] = GSBaseManager.getDeliverGoodsTime(tGSOrderManufactureVO.delivertime);
					tStr[11] = GSBaseManager.getOrderDetailStatusName(tGSOrderManufactureVO.orderDetailStatus);
					tList.add(tStr);
				}
			}
		} catch (GSException ge) {
			throw ge;
		} catch (Exception e) {
			GSLogWriter.error(this, e.toString());
			throw new GSException(GSException.E10042, GSException.E10042_MSG);
		}
		return tList;

	}

	/**
	 * 查询待调整的订单明细信息
	 * 
	 * @param aOrderDtlMofVO
	 *            查询参数VO
	 * @param aOrg
	 *            可查询组织
	 * @param aMap
	 *            存放集中编码对应的供应商集合
	 * @param pageNo
	 *            页号
	 * @param pageSize
	 *            页大小
	 * @return
	 * @throws GSException
	 */
	public ArrayList getOrderDetailForModify(GSOrderDetailModifyVO aOrderDtlMofVO, HashMap aMap, int pageNo, int pageSize) throws GSException {
		ArrayList tList = new ArrayList();
		ArrayList tRs = new ArrayList();
		Connection tConn = null;
		GSOrderDetailDAO tOrderDetailDAO = new GSOrderDetailDAO();
		try {
			tConn = tOrderDetailDAO.getConnetion();
			// 查询待更改的订单明细信息
			tRs = tOrderDetailDAO.queryOrderDetailForMod(tConn, aOrderDtlMofVO, pageNo, pageSize);
			if (tRs.size() > 0) {
				// 重新封装查询结果
				GSProviderDAO tProviderDAO = new GSProviderDAO();
				for (int i = 0; i < tRs.size(); i++) {
					String[] tStr = new String[24];
					GSOrderAnaDetailAndCategoryBean tGSOrder = (GSOrderAnaDetailAndCategoryBean) tRs.get(i);
					tStr[0] = tGSOrder.getGs_order_detail_id();
					tStr[1] = tGSOrder.getGs_concentricity_id();
					// 查询集中编码所有的供应商信息
					ArrayList tProv = tProviderDAO.queryProvider(tConn, tStr[1]);
					aMap.put(tStr[1], tProv);
					tStr[2] = tGSOrder.getName_product();
					tStr[3] = tGSOrder.getSpec();
					tStr[4] = tGSOrder.getModel();
					tStr[5] = tGSOrder.getProduct_brand();
					tStr[6] = tGSOrder.getName_warehouse();
					tStr[7] = tGSOrder.getIs_tradeflat_product();
					tStr[8] = tGSOrder.getName();
					tStr[9] = StringUtils.formatEDouble(tGSOrder.getGs_order_count(), 2);
					tStr[10] = tGSOrder.getProduct_unit();
					tStr[11] = StringUtils.formatEDouble(tGSOrder.getGs_goods_unitprice(), 4);
					double temp = tGSOrder.getGs_goods_unitprice() * tGSOrder.getGs_order_count();
					tStr[12] = StringUtils.formatEDouble(temp, 4);
					tStr[13] = tGSOrder.getGs_order_detail_status();
					tStr[14] = tGSOrder.getGs_deliver_goods_date();
					tStr[15] = tGSOrder.getGs_deliver_goods_time();
					tStr[16] = tGSOrder.getCode();
					tStr[17] = tGSOrder.getGs_order_tempid_order();
					tStr[18] = tGSOrder.getIs_tradeflat_provider();
					tStr[19] = tGSOrder.getGs_balance_mode();
					tStr[20] = DefineDic.getBalanceMode(tGSOrder.getGs_balance_mode());
					tStr[21] = tGSOrder.getGs_orderreturn_sign();
					tStr[22] = tGSOrder.getIs_normal();
					tStr[23] = tGSOrder.getDrawing_piece_code();
					tList.add(tStr);
				}
			}
		} catch (GSException ge) {
			throw ge;
		} catch (Exception e) {
			GSLogWriter.error(this, e.toString());
			throw new GSException(GSException.E00001, GSException.E00001_MSG);
		} finally {
			GSOrderDetailDAO.close(tConn);
		}
		return tList;
	}

	/**
	 * 查询维护管理订单明细信息
	 * 
	 * @param aOrderDtlMofVO
	 *            查询参数VO
	 * @param aOrg
	 *            可查询组织
	 * @param aMap
	 *            存放集中编码对应的供应商集合
	 * @param pageNo
	 *            页号
	 * @param pageSize
	 *            页大小
	 * @return
	 * @throws GSException
	 */
	public ArrayList getManagerOrderForModify(GSOrderDetailModifyVO aOrderDtlMofVO, ArrayList aOrg, HashMap aMap, int pageNo, int pageSize) throws GSException {
		ArrayList tList = new ArrayList();
		ArrayList tRs = new ArrayList();
		Connection tConn = null;
		GSOrderDetailDAO tOrderDetailDAO = new GSOrderDetailDAO();
		try {
			tConn = tOrderDetailDAO.getConnetion();
			// 查询待更改的订单明细信息
			tRs = tOrderDetailDAO.queryManagerOrderForMod(tConn, aOrderDtlMofVO, aOrg, pageNo, pageSize);
			if (tRs.size() > 0) {
				// 重新封装查询结果
				GSProviderDAO tProviderDAO = new GSProviderDAO();
				for (int i = 0; i < tRs.size(); i++) {
					String[] tStr = new String[20];
					GSOrderDetailModifyVO tGSOrder = (GSOrderDetailModifyVO) tRs.get(i);
					tStr[0] = tGSOrder.orderDetailId;
					tStr[1] = tGSOrder.concentricityId;
					// 查询集中编码所有的供应商信息
					ArrayList tProv = tProviderDAO.queryProvider(tConn, tStr[1]);
					aMap.put(tStr[1], tProv);
					tStr[2] = tGSOrder.manufName;
					tStr[3] = tGSOrder.manufSpec;
					tStr[4] = tGSOrder.manufType;
					tStr[5] = tGSOrder.manufBrand;
					tStr[6] = tGSOrder.orderDeptName;
					tStr[7] = tGSOrder.isTradeFlatManuf;
					tStr[8] = tGSOrder.providerName;
					tStr[9] = StringUtils.formatEDouble(tGSOrder.orderCount, 2);
					tStr[10] = tGSOrder.quantUnit;
					tStr[11] = StringUtils.formatEDouble(tGSOrder.goodsUnitprice, 4);
					double temp = tGSOrder.goodsUnitprice * tGSOrder.orderCount;
					tStr[12] = StringUtils.formatEDouble(temp, 4);
					tStr[13] = tGSOrder.orderDetailStatus;
					tStr[14] = tGSOrder.deliverGoodsDate;
					tStr[15] = tGSOrder.deliverGoodsTime;
					tStr[16] = tGSOrder.providerId;
					tStr[17] = tGSOrder.orderId;
					tStr[18] = tGSOrder.isTradFlatProvider;
					tStr[19] = tGSOrder.deliverGoodsId;
					tList.add(tStr);
				}
			}
		} catch (GSException ge) {
			throw ge;
		} catch (Exception e) {
			GSLogWriter.error(this, e.toString());
			throw new GSException(GSException.E00001, GSException.E00001_MSG);
		} finally {
			GSOrderDetailDAO.close(tConn);
		}
		return tList;
	}

	/**
	 * 订单明细信息调整保存
	 * 
	 * @param aList
	 * @return
	 * @throws GSException
	 */
	public String updateOrderDetail(ArrayList aList, LoginContext context) throws GSException {
		Connection tConn = null;
		GSOrderDetailDAO tOrderDetailDAO = new GSOrderDetailDAO();
		boolean tFlag = false;
		int err = 0;
		int ok = 0;
		String msg = "";
		try {
			tConn = tOrderDetailDAO.getConnetion();
			tConn.setAutoCommit(false);
			if (aList.size() > 0) {
				String tRs = "";
				// 逐笔保存订单修改明细
				for (int i = 0; i < aList.size(); i++) {
					GSOrderDetailModifyVO tOrderDetlModVO = (GSOrderDetailModifyVO) aList.get(i);
					GSOrderAnaDetailAndCategoryBean tDBOrderDetailBean = tOrderDetailDAO.getOrderDetailByDetailId(tOrderDetlModVO.orderDetailId);
					tDBOrderDetailBean.setGs_order_count(tOrderDetlModVO.orderCount);
					tDBOrderDetailBean.setGs_provider_id(tOrderDetlModVO.providerId);
					tDBOrderDetailBean.setGs_manufacture_id(tOrderDetlModVO.manufId);
					tDBOrderDetailBean.setGs_balance_mode(tOrderDetlModVO.mode);
					tDBOrderDetailBean.setGs_goods_unitprice(tOrderDetlModVO.goodsUnitprice);
					tDBOrderDetailBean.setGs_deliver_goods_date(tOrderDetlModVO.deliverGoodsDate);
					tDBOrderDetailBean.setGs_deliver_goods_time(tOrderDetlModVO.deliverGoodsTime);
					tDBOrderDetailBean.setGs_lastmodifer_id(tOrderDetlModVO.lastModifyId);
					tDBOrderDetailBean.setGs_lastmodify_contents(tOrderDetlModVO.lastModifyContent);
					tDBOrderDetailBean.setGs_order_detail_status(tOrderDetlModVO.orderDetailStatus);
					tFlag = tOrderDetailDAO.updateOrderDetail(tConn, tDBOrderDetailBean);
					if (!tOrderDetlModVO.orderDetailStatus.equals(GSBaseConstants.ORDER_AUTHORISE)
							&& GSBaseConstants.APEP_RETURN_SIGN_SUCCESS.equals(tOrderDetlModVO.sign)) {
						if (tFlag) {
							tRs = GSCommunicationApepProcessor.modifyOrderDetailApep(tDBOrderDetailBean, context);
							String[] result = GSCommunicationApepProcessor.parseReturnXml(tRs);
							if (result[0].equals(GSBaseConstants.APEP_RETURN_SIGN_SUCCESS)) {
								ok++;
								tConn.commit();
								GSLogWriter.debug(this, "提交返回成功");
							} else {
								err++;
								tConn.rollback();
								GSLogWriter.error(this, "提交返回失败");
							}
						} else {
							GSLogWriter.debug(this, "订单明细内容修改保存失败");
							tConn.rollback();
							break;
						}
					} else {
						ok++;
						GSLogWriter.info("不需要向交易平台提交修改信息，直接修改订单明细状态");
						tConn.commit();
					}
				}
				if (err == 0) {
					msg = "有" + ok + "笔订单修改保存成功";
				} else if (err > 0) {
					msg = "有" + ok + "笔订单修改保存成功,有" + err + "笔订单修改保存并提交到APEP失败";
				}
			}
		} catch (GSException ge) {
			try {
				if (tConn != null) {
					tConn.rollback();
				}
			} catch (SQLException se) {
				se.printStackTrace();
			}
			throw ge;
		} catch (Exception e) {
			try {
				if (tConn != null) {
					tConn.rollback();
				}
			} catch (SQLException se) {
				se.printStackTrace();
			}
			GSLogWriter.error(this, e.toString());
			throw new GSException(GSException.E10053, GSException.E10053_MSG);
		} finally {
			GSOrderDetailDAO.close(tConn);
		}
		return msg;
	}

	/**
	 * 运营公司人员在订单查询页面 选择订单编码查询订单明细信息
	 * 
	 * @param aOrderId
	 *            订单编码
	 * @return
	 * @throws GSException
	 */
	public ArrayList getOrderQueryDetailByOrderId(String aOrderId) throws GSException {
		ArrayList tList = new ArrayList();
		try {
			GSOrderDetailDAO tGSOrderDetailDAO = new GSOrderDetailDAO();
			// 查询订单明细
			ArrayList tRs = tGSOrderDetailDAO.queryOrderQueryDetail(aOrderId);
			if (tRs.size() > 0) {
				for (int i = 0; i < tRs.size(); i++) {
					String[] tStr = new String[34];
					GSOrderQueryDetailExVO tGSOrderManufactureExVO = (GSOrderQueryDetailExVO) tRs.get(i);
					// 取出订单包含的产品信息VO对象组成String数组
					tStr[0] = tGSOrderManufactureExVO.orderDetailId;
					tStr[1] = tGSOrderManufactureExVO.concentricityId;
					tStr[2] = tGSOrderManufactureExVO.manufactureName;
					tStr[3] = tGSOrderManufactureExVO.manufSpec;
					tStr[4] = tGSOrderManufactureExVO.manufType;
					tStr[5] = tGSOrderManufactureExVO.manufBrand;
					tStr[6] = StringUtils.formatEDouble(tGSOrderManufactureExVO.ordercount, 2) + tGSOrderManufactureExVO.quantUnit;
					// if(tGSOrderManufactureVO.orderDetailStatus.equals(GSBaseConstants.ORDER_DELIVERY_CONFIRM)
					// ||
					// tGSOrderManufactureVO.orderDetailStatus.equals(GSBaseConstants.ORDER_ORDER_CONFIRM)){
					tStr[7] = StringUtils.formatEDouble(tGSOrderManufactureExVO.goodsUnitprice, 4);
					tStr[8] = StringUtils.formatEDouble(tGSOrderManufactureExVO.goodsUnitprice * tGSOrderManufactureExVO.ordercount, 4);
					// }else{
					// tStr[7] = "";
					// tStr[8] = "";
					// }
					tStr[9] = tGSOrderManufactureExVO.deliverdate;
					tStr[10] = tGSOrderManufactureExVO.delivertime.equals("") ? "" : GSBaseManager.getDeliverGoodsTime(tGSOrderManufactureExVO.delivertime);
					tStr[11] = GSBaseManager.getOrderDetailStatusName(tGSOrderManufactureExVO.orderDetailStatus);
					tStr[12] = tGSOrderManufactureExVO.authorizeadvices;
					tStr[13] = tGSOrderManufactureExVO.period;
					tStr[14] = tGSOrderManufactureExVO.authorizeid;
					tStr[15] = tGSOrderManufactureExVO.authorizedate;
					tStr[16] = tGSOrderManufactureExVO.orderDetailStatus;
					tStr[17] = tGSOrderManufactureExVO.canceladvices;
					tStr[18] = tGSOrderManufactureExVO.cancelid;
					tStr[19] = tGSOrderManufactureExVO.canceldate;
					tStr[20] = tGSOrderManufactureExVO.rejectcause;
					tStr[21] = tGSOrderManufactureExVO.rejectdate;
					tStr[22] = tGSOrderManufactureExVO.rejecttime;
					tStr[23] = tGSOrderManufactureExVO.delivergoodsid;
					tStr[24] = tGSOrderManufactureExVO.delivergoodsdate;
					tStr[25] = tGSOrderManufactureExVO.delivergoodstime;
					tStr[26] = tGSOrderManufactureExVO.deliveryman;
					tStr[27] = tGSOrderManufactureExVO.deliveryphone;
					tStr[28] = tGSOrderManufactureExVO.delivercounts;
					tStr[29] = tGSOrderManufactureExVO.signindate;
					tStr[30] = tGSOrderManufactureExVO.signinperson;
					tStr[31] = tGSOrderManufactureExVO.signincount;
					tStr[32] = tGSOrderManufactureExVO.providerId;
					tStr[33] = tGSOrderManufactureExVO.providerShtName;
					tList.add(tStr);
				}
			}
		} catch (GSException ge) {
			throw ge;
		} catch (Exception e) {
			GSLogWriter.error(this, e.toString());
			throw new GSException(GSException.E10042, GSException.E10042_MSG);
		}
		return tList;
	}

	/**
	 * 运营公司查询申购单状态跟踪
	 * 
	 * @param aOrderId
	 * @return
	 * @throws GSException
	 */
	public ArrayList getOrderStatusTraceDetailByOrderId(String aOrderId) throws GSException {
		ArrayList tList = new ArrayList();
		try {
			GSOrderDetailDAO tGSOrderDetailDAO = new GSOrderDetailDAO();
			// 查询订单明细
			ArrayList tRs = tGSOrderDetailDAO.queryOrderStatusTraceDetail(aOrderId);
			if (tRs.size() > 0) {
				for (int i = 0; i < tRs.size(); i++) {
					String[] tStr = new String[13];
					GSOrderStatusTraceDetailVO tGSOrderManufactureVO = (GSOrderStatusTraceDetailVO) tRs.get(i);
					// 取出订单包含的产品信息VO对象组成String数组
					tStr[0] = tGSOrderManufactureVO.orderDetailId;
					tStr[1] = tGSOrderManufactureVO.concentricityId;
					tStr[2] = tGSOrderManufactureVO.manufactureName;
					tStr[3] = tGSOrderManufactureVO.manufSpec;
					tStr[4] = tGSOrderManufactureVO.manufType;
					tStr[5] = tGSOrderManufactureVO.manufBrand;
					tStr[6] = StringUtils.formatEDouble(tGSOrderManufactureVO.ordercount, 2) + tGSOrderManufactureVO.quantUnit;
					tStr[7] = GSBaseManager.getOrderDetailStatusName(tGSOrderManufactureVO.orderDetailStatus);
					// if(tGSOrderManufactureVO.orderDetailStatus.equals(GSBaseConstants.ORDER_ORDER_CONFIRM)
					// ||
					// tGSOrderManufactureVO.orderDetailStatus.equals(GSBaseConstants.ORDER_DELIVERY_CONFIRM)){
					tStr[8] = StringUtils.formatEDouble(tGSOrderManufactureVO.goodUnitprice, 4);
					tStr[9] = StringUtils.formatEDouble(tGSOrderManufactureVO.goodUnitprice * tGSOrderManufactureVO.ordercount, 4);
					// }else{
					// tStr[8] = "";
					// tStr[9] = "";
					// }
					tStr[10] = tGSOrderManufactureVO.deliverdate;
					tStr[11] = tGSOrderManufactureVO.delivertime;
					tStr[12] = tGSOrderManufactureVO.period;
					tList.add(tStr);
				}
			}
		} catch (GSException ge) {
			throw ge;
		} catch (Exception e) {
			GSLogWriter.error(this, e.toString());
			throw new GSException(GSException.E10042, GSException.E10042_MSG);
		}
		return tList;
	}

	/**
	 * 运营公司操作员根据订单编码 查询待提交的的订单明细信息
	 * 
	 * @param aOrderId
	 *            订单编码
	 * @return
	 * @throws GSException
	 */
	public ArrayList getOrderSubmitDetail(String aOrderId) throws GSException {
		ArrayList tList = new ArrayList();
		try {
			GSOrderDetailDAO tGSOrderDetailDAO = new GSOrderDetailDAO();
			// 查询订单明细
			ArrayList tRs = tGSOrderDetailDAO.queryOrderSubmitDetail(aOrderId);
			if (tRs.size() > 0) {
				for (int i = 0; i < tRs.size(); i++) {
					String[] tStr = new String[14];
					GSOrderSubmitDetailVO tGSOrdStDtlVO = (GSOrderSubmitDetailVO) tRs.get(i);
					// 取出订单包含的产品信息VO对象组成String数组
					tStr[0] = tGSOrdStDtlVO.orderId;
					tStr[1] = tGSOrdStDtlVO.concentricityId;
					tStr[2] = tGSOrdStDtlVO.manufactureName;
					tStr[3] = tGSOrdStDtlVO.manufSpec;
					tStr[4] = tGSOrdStDtlVO.manufType;
					tStr[5] = tGSOrdStDtlVO.manufBrand;
					tStr[6] = StringUtils.formatEDouble(tGSOrdStDtlVO.ordercount, 2);
					tStr[7] = tGSOrdStDtlVO.quantUnit;
					tStr[8] = tGSOrdStDtlVO.deliverdate;
					tStr[9] = GSBaseManager.getDeliverGoodsTime(tGSOrdStDtlVO.delivertime);
					tStr[10] = tGSOrdStDtlVO.orderId;
					tStr[11] = tGSOrdStDtlVO.orderDetailId;
					tStr[12] = StringUtils.formatEDouble(tGSOrdStDtlVO.manufactureUnitPrice, 4);
					tStr[13] = tGSOrdStDtlVO.period;
					tList.add(tStr);
				}
			}
		} catch (GSException ge) {
			throw ge;
		} catch (Exception e) {
			GSLogWriter.error(this, e.toString());
			throw new GSException(GSException.E10042, GSException.E10042_MSG);
		}
		return tList;
	}
	
	//增加图件号的查询
	public ArrayList getOrderSubmitDetailAddDwring(String aOrderId) throws GSException {
		ArrayList tList = new ArrayList();
		try {
			GSOrderDetailDAO tGSOrderDetailDAO = new GSOrderDetailDAO();
			// 查询订单明细
			ArrayList tRs = tGSOrderDetailDAO.queryOrderSubmitDetailAddDrawing(aOrderId);
			if (tRs.size() > 0) {
				for (int i = 0; i < tRs.size(); i++) {
					String[] tStr = new String[15];
					GSOrderSubmitDetailVO tGSOrdStDtlVO = (GSOrderSubmitDetailVO) tRs.get(i);
					// 取出订单包含的产品信息VO对象组成String数组
					tStr[0] = tGSOrdStDtlVO.orderId;
					tStr[1] = tGSOrdStDtlVO.concentricityId;
					tStr[2] = tGSOrdStDtlVO.manufactureName;
					tStr[3] = tGSOrdStDtlVO.manufSpec;
					tStr[4] = tGSOrdStDtlVO.manufType;
					tStr[5] = tGSOrdStDtlVO.manufBrand;
					tStr[6] = StringUtils.formatEDouble(tGSOrdStDtlVO.ordercount, 2);
					tStr[7] = tGSOrdStDtlVO.quantUnit;
					tStr[8] = tGSOrdStDtlVO.deliverdate;
					tStr[9] = GSBaseManager.getDeliverGoodsTime(tGSOrdStDtlVO.delivertime);
					tStr[10] = tGSOrdStDtlVO.orderId;
					tStr[11] = tGSOrdStDtlVO.orderDetailId;
					tStr[12] = StringUtils.formatEDouble(tGSOrdStDtlVO.manufactureUnitPrice, 4);
					tStr[13] = tGSOrdStDtlVO.period;
					tStr[14] = tGSOrdStDtlVO.dwringPieceCode;
					tList.add(tStr);
				}
			}
		} catch (GSException ge) {
			throw ge;
		} catch (Exception e) {
			GSLogWriter.error(this, e.toString());
			throw new GSException(GSException.E10042, GSException.E10042_MSG);
		}
		return tList;
	}

	/**
	 * 取得运营公司所有待提交订单及明细信息
	 * 
	 * @param aGSOrderVO
	 *            封装订单查询参数的VO对象
	 * @param aOrg
	 *            可操作订货单位对象
	 * @return
	 * @throws GSException
	 */
	public ArrayList getSubmitOrderAndDetail(GSOrderSubmitVO aGSOrderVO, ArrayList aOrg) throws GSException {
		ArrayList tOrderList = new ArrayList();
		GSOrderDAO tGSOrderDAO = new GSOrderDAO();
		ArrayList tList = new ArrayList();
		Connection tConn = null;
		try {
			// 取得DB连接
			tConn = tGSOrderDAO.getConnetion();
			String[] tDateStr = new String[2];
			tDateStr[0] = aGSOrderVO.orderCreateDateStr;
			tDateStr[1] = aGSOrderVO.orderCreateDateEnd;
			tDateStr = DateUtil.formateDate(tDateStr);
			aGSOrderVO.orderCreateDateStr = tDateStr[0];
			aGSOrderVO.orderCreateDateEnd = tDateStr[1];
			// 查询所有订单及明细
			tOrderList = tGSOrderDAO.queryUncommitOrderAndDetail(tConn, aGSOrderVO, aOrg);
			if (tOrderList.size() > 0) {
				String tOrderId = "";
				String tConCentricityId = "";
				GSOrderVO tGSOrderVO = null;
				for (int i = 0; i < tOrderList.size(); i++) {

					GSOrderSubmitOfWorkingVO tGSOrderSubmitVO = (GSOrderSubmitOfWorkingVO) tOrderList.get(i);
					String m = DefineDic.getBalanceMode(tGSOrderSubmitVO.mode);
					// 判断新取得的OrderSubmitVO对象中的订单编号是否与前一对象中订单编号相同
					if (tOrderId.equals(tGSOrderSubmitVO.orderid)) {
						// 订单编号相同则将取得的产品信息放入同一订单VO对象的ArrayList对象中
						if (tConCentricityId.equals(tGSOrderSubmitVO.concentricityId)) {
							continue;
						}
						String[] tStr = new String[10];
						tStr[0] = tGSOrderSubmitVO.concentricityId;
						tStr[1] = tGSOrderSubmitVO.manufactureName;
						tStr[2] = tGSOrderSubmitVO.manufSpec;
						tStr[3] = tGSOrderSubmitVO.manufType;
						tStr[4] = tGSOrderSubmitVO.manufBrand;
						tStr[5] = StringUtils.formatEDouble(tGSOrderSubmitVO.orderCount, 2);
						tStr[6] = tGSOrderSubmitVO.quantUnit;
						tStr[7] = tGSOrderSubmitVO.orderDetailId;
						tStr[8] = GSBaseManager.getOrderDetailStatusName(tGSOrderSubmitVO.orderDetailStatus);
						tStr[9] = m;
						tGSOrderVO.tList.add(tStr);
					} else {
						// 订单编号不同创建新的订单VO对象
						tGSOrderVO = new GSOrderVO();
						tGSOrderVO.orderid = tGSOrderSubmitVO.orderid;
						tGSOrderVO.orderStatus = GSBaseManager.getOrderStatusName(tGSOrderSubmitVO.orderStatus);
						tGSOrderVO.orderDeptName = tGSOrderSubmitVO.orderDeptName;
						tGSOrderVO.deliverMode = GSBaseManager.getDeliverModeName(tGSOrderSubmitVO.deliverMode);
						tGSOrderVO.balanceMode = GSBaseManager.getBalanceModeName(tGSOrderSubmitVO.balanceMode);
						tGSOrderVO.orderCreateDate = tGSOrderSubmitVO.orderCreateDate;
						tGSOrderVO.recorderId = tGSOrderSubmitVO.creater;
						tGSOrderVO.orderDeptId = tGSOrderSubmitVO.orderDeptId;
						tGSOrderVO.deliverGoodsAddr = tGSOrderSubmitVO.deliverGoodsAddr;
						tGSOrderVO.contactName = tGSOrderSubmitVO.contactName;
						tGSOrderVO.contactPhone = tGSOrderSubmitVO.contactPhone;
						tGSOrderVO.notes = tGSOrderSubmitVO.notes;
						tGSOrderVO.tList = new ArrayList();

						String[] tStr = new String[10];
						tStr[0] = tGSOrderSubmitVO.concentricityId;
						tStr[1] = tGSOrderSubmitVO.manufactureName;
						tStr[2] = tGSOrderSubmitVO.manufSpec;
						tStr[3] = tGSOrderSubmitVO.manufType;
						tStr[4] = tGSOrderSubmitVO.manufBrand;
						tStr[5] = StringUtils.formatEDouble(tGSOrderSubmitVO.orderCount, 2);
						tStr[6] = tGSOrderSubmitVO.quantUnit;
						tStr[7] = tGSOrderSubmitVO.orderDetailId;
						tStr[8] = GSBaseManager.getOrderDetailStatusName(tGSOrderSubmitVO.orderDetailStatus);
						tStr[9] = m;
						tConCentricityId = tGSOrderSubmitVO.concentricityId;
						tGSOrderVO.tList.add(tStr);

						tOrderId = tGSOrderSubmitVO.orderid;
						// 将订单VO对象放入结果集对象
						tList.add(tGSOrderVO);
					}

				}
			}
		} catch (GSException ge) {
			throw ge;
		} catch (Exception e) {
			GSLogWriter.debug(this, e.toString());
			throw new GSException(GSException.E10041, GSException.E10041_MSG);
		} finally {
			GSOrderDAO.close(tConn);
		}
		return tList;
	}

	/**
	 * 取得所有待手工处理签收的订单
	 * 
	 * @param aOrderVOForNonFlat
	 *            查询参数VO
	 * @param tOrg
	 *            可查询订货单位
	 * @param pageNo
	 *            页号
	 * @param pageSize
	 *            页大小
	 * @return
	 * @throws GSException
	 */
	public ArrayList getOrderDetailForNonFlatsdProvider(GSOrderSubmitForNonFlatVO aOrderVOForNonFlat, int pageNo, int pageSize) throws GSException {
		ArrayList tList = new ArrayList();
		GSOrderDetailDAO tOrderDetailDAO = new GSOrderDetailDAO();
		// 查询待提交的非交易平台商户所有的订单信息
		ArrayList tRs = tOrderDetailDAO.queryUncommitOrderInfoForNonFlatsdProv(aOrderVOForNonFlat, pageNo, pageSize);
		if (tRs.size() > 0) {
			// 取出查询到的订单信息重新封装，便于页面显示
			for (int i = 0; i < tRs.size(); i++) {
				String[] tStr = new String[28];
				GSOrderAnaDetailAndCategoryBean tGSOrderForNonFlat = (GSOrderAnaDetailAndCategoryBean) tRs.get(i);
				tStr[0] = tGSOrderForNonFlat.getGs_order_detail_id();
				tStr[1] = tGSOrderForNonFlat.getGs_order_detail_status();
				tStr[2] = tGSOrderForNonFlat.getGs_concentricity_id();
				tStr[3] = tGSOrderForNonFlat.getName_product();
				tStr[4] = tGSOrderForNonFlat.getIs_tradeflat_product();
				tStr[5] = tGSOrderForNonFlat.getSpec();
				tStr[6] = tGSOrderForNonFlat.getModel();
				tStr[7] = tGSOrderForNonFlat.getProduct_brand();
				tStr[8] = tGSOrderForNonFlat.getName();
				tStr[9] = StringUtils.formatEDouble(tGSOrderForNonFlat.getGs_order_count(), 2);
				tStr[10] = tGSOrderForNonFlat.getProduct_unit();
				tStr[11] = StringUtils.formatEDouble(tGSOrderForNonFlat.getGs_goods_unitprice(), 4);
				tStr[12] = StringUtils.formatEDouble(tGSOrderForNonFlat.getGs_goods_unitprice() * tGSOrderForNonFlat.getGs_order_count(), 4);
				tStr[13] = tGSOrderForNonFlat.getName_warehouse();
				tStr[14] = tGSOrderForNonFlat.getGs_deliver_goods_date();
				tStr[15] = GSBaseManager.getDeliverGoodsTime(tGSOrderForNonFlat.getGs_deliver_goods_time());
				tStr[16] = tGSOrderForNonFlat.getCode();
				tStr[17] = tGSOrderForNonFlat.getGs_order_tempid_order();
				tStr[18] = tGSOrderForNonFlat.getAppender_property();
				tStr[19] = tGSOrderForNonFlat.getApep_code();
				tStr[20] = tGSOrderForNonFlat.getIs_tradeflat_provider();
				tStr[21] = tGSOrderForNonFlat.getGs_deliver_goods_time();
				tStr[22] = tGSOrderForNonFlat.getManager_tel();
				tStr[23] = tGSOrderForNonFlat.getAddress();
				tStr[24] = tGSOrderForNonFlat.getGs_deliver_goods_addr();
				tStr[25] = tGSOrderForNonFlat.getIs_normal();
				tStr[26] = tGSOrderForNonFlat.getGs_orderreturn_content();
				tStr[27] = tGSOrderForNonFlat.getDrawing_piece_code();
				tList.add(tStr);
			}
		}
		return tList;
	}

	/**
	 * 取得所有非网上待签收的订单
	 * 
	 * @param aOrderVOForNonFlat
	 *            查询参数VO
	 * @param tOrg
	 *            可查询订货单位
	 * @param pageNo
	 *            页号
	 * @param pageSize
	 *            页大小
	 * @return
	 * @throws GSException
	 */
	public ArrayList getOrderDetailForNonFlatProvider(GSOrderSubmitForNonFlatVO aOrderVOForNonFlat, ArrayList tOrg, int pageNo, int pageSize)
	throws GSException {
		ArrayList tList = new ArrayList();
		GSOrderDetailDAO tOrderDetailDAO = new GSOrderDetailDAO();
		// 查询待提交的非交易平台商户所有的订单信息
		ArrayList tRs = tOrderDetailDAO.queryUncommitOrderInfoForNonFlatProv(aOrderVOForNonFlat, tOrg, pageNo, pageSize);
		if (tRs.size() > 0) {
			// 取出查询到的订单信息重新封装，便于页面显示
			for (int i = 0; i < tRs.size(); i++) {
				String[] tStr = new String[20];
				GSOrderSubmitForNonFlatVO tGSOrderForNonFlat = (GSOrderSubmitForNonFlatVO) tRs.get(i);
				tStr[0] = tGSOrderForNonFlat.orderDetailId;
				tStr[1] = tGSOrderForNonFlat.orderDetailStatus;
				tStr[2] = tGSOrderForNonFlat.concentricityId;
				tStr[3] = tGSOrderForNonFlat.manfName;
				tStr[4] = tGSOrderForNonFlat.isTradeFlatManuf;
				tStr[5] = tGSOrderForNonFlat.manufSpec;
				tStr[6] = tGSOrderForNonFlat.manufType;
				tStr[7] = tGSOrderForNonFlat.manufBrand;
				tStr[8] = tGSOrderForNonFlat.providerName;
				tStr[9] = StringUtils.formatEDouble(tGSOrderForNonFlat.orderCount, 2);
				tStr[10] = tGSOrderForNonFlat.quantUnit;
				tStr[11] = StringUtils.formatEDouble(tGSOrderForNonFlat.goodsUnitprice, 4);
				tStr[12] = StringUtils.formatEDouble(tGSOrderForNonFlat.goodsUnitprice * tGSOrderForNonFlat.orderCount, 4);
				tStr[13] = tGSOrderForNonFlat.orderDeptName;
				tStr[14] = tGSOrderForNonFlat.deliverGoodsDate;
				tStr[15] = GSBaseManager.getDeliverGoodsTime(tGSOrderForNonFlat.deliverGoodsTime);
				tStr[16] = tGSOrderForNonFlat.providerId;
				tStr[17] = tGSOrderForNonFlat.orderId;
				tStr[18] = tGSOrderForNonFlat.appenderProperty;
				tStr[19] = tGSOrderForNonFlat.mode;
				tList.add(tStr);
			}
		}
		return tList;
	}

	/**
	 * 非交易平台商户订单明细提交
	 * 
	 * @param aOrderDetailId
	 *            订单明细编码
	 * @param aOperId
	 *            操作员编码
	 * @return 提交成功返回true,失败返回false
	 * @throws GSException
	 */
	public boolean submitOrderDetailForNonFlat(String[] aOrderDetailId, String aOperId) throws GSException {
		Connection tConn = null;
		GSOrderDetailDAO tGSOrderDetailDAO = new GSOrderDetailDAO();
		boolean tFlag = false;
		try {
			// 取得DB连接
			tConn = tGSOrderDetailDAO.getConnetion();
			tConn.setAutoCommit(false);
			// 循环取出待提交订单明细并封装到订单明细Bean对象
			for (int i = 0; i < aOrderDetailId.length; i++) {
				GSOrderDetailBean tOrderDetailBean = new GSOrderDetailBean();
				tOrderDetailBean.setGs_order_detail_id(aOrderDetailId[i]);
				tOrderDetailBean.setGs_order_detail_status(GSBaseConstants.ORDER_ORDER_CONFIRM);
				tOrderDetailBean.setGs_lastmodifer_id(aOperId);
				tOrderDetailBean.setGs_lastmodify_contents("网下订单明细提交");
				String tCurDT = DateUtil.formateDateTime(DateUtil.getCurrentTime("DT", "AD"));
				tOrderDetailBean.setGs_lastmodify_date(tCurDT);
				// 修改订单明细状态为订货中
				tFlag = tGSOrderDetailDAO.updateOrderDetailStatus(tOrderDetailBean, tConn, GSBaseConstants.ORDER_ORDERING);
				if (tFlag) {
					continue;
				} else {
					GSLogWriter.debug(this, "订单明细状态修改失败：OrderDetailId=" + aOrderDetailId[i]);
					tConn.rollback();
					break;
				}
			}
			if (tFlag) {
				tConn.commit();
			}
		} catch (GSException ge) {
			throw ge;
		} catch (Exception e) {
			GSLogWriter.error(this, e.toString());
			throw new GSException(GSException.E10051, GSException.E10051_MSG);
		} finally {
			GSOrderDetailDAO.close(tConn);
		}
		return tFlag;
	}

	/**
	 * 非交易平台商户订单明细提交
	 * 
	 * @param aOrderDetailId
	 *            订单明细编码
	 * @param aOperId
	 *            操作员编码
	 * @return 提交成功返回true,失败返回false
	 * @throws GSException
	 */
	public boolean submitOrderDetailForNonFlatsd(String[] aOrderDetailId, String aOperId) throws GSException {
		Connection tConn = null;
		GSOrderDetailDAO tGSOrderDetailDAO = new GSOrderDetailDAO();
		boolean tFlag = false;
		try {
			// 取得DB连接
			tConn = tGSOrderDetailDAO.getConnetion();
			tConn.setAutoCommit(false);
			// 循环取出待提交订单明细并封装到订单明细Bean对象
			for (int i = 0; i < aOrderDetailId.length; i++) {
				GSOrderDetailBean tOrderDetailBean = new GSOrderDetailBean();
				tOrderDetailBean.setGs_order_detail_id(aOrderDetailId[i]);
				tOrderDetailBean.setGs_order_detail_status(GSBaseConstants.ORDER_ORDER_CONFIRM);
				tOrderDetailBean.setGs_lastmodifer_id(aOperId);
				tOrderDetailBean.setGs_lastmodify_contents("手工订单明细提交");
				String tCurDT = DateUtil.formateDateTime(DateUtil.getCurrentTime("DT", "AD"));
				tOrderDetailBean.setGs_lastmodify_date(tCurDT);
				// 修改订单明细状态为已确认（订单确认,送货确认）
				tFlag = tGSOrderDetailDAO.updateOrderDetailStatus(tOrderDetailBean, tConn, GSBaseConstants.ORDER_ORDERING);
				if (tFlag) {
					continue;
				} else {
					GSLogWriter.debug(this, "订单明细状态修改失败：OrderDetailId=" + aOrderDetailId[i]);
					tConn.rollback();
					break;
				}
			}
			if (tFlag) {
				tConn.commit();
			}
		} catch (GSException ge) {
			throw ge;
		} catch (Exception e) {
			GSLogWriter.error(this, e.toString());
			throw new GSException(GSException.E10051, GSException.E10051_MSG);
		} finally {
			GSOrderDetailDAO.close(tConn);
		}
		return tFlag;
	}

	/**
	 * 运营公司级申购综合查询订单
	 * 
	 * @param aOrderVO
	 *            传入的查询参数VO对象
	 * @param aOrg
	 *            可查询订货单位ArrayList对象
	 * @param pageNo
	 *            页号
	 * @param pageSize
	 *            页大小
	 * @return
	 * @throws GSException
	 */
	public ArrayList getOrderDetailByOpt(GSOrderVO aOrderVO, int pageNo, int pageSize) throws GSException {
		String[] tDateStr = new String[2];
		// 取得查询参数订单创建最小日期和最大日期
		tDateStr[0] = aOrderVO.orderCreateDateLowLimie;
		tDateStr[1] = aOrderVO.orderCreateDateUprLimie;
		// 格式化日期
		tDateStr = DateUtil.formateDate(tDateStr);
		aOrderVO.orderCreateDateLowLimie = tDateStr[0];
		aOrderVO.orderCreateDateUprLimie = tDateStr[1];

		GSOrderDetailDAO tOrderDtlDAO = new GSOrderDetailDAO();
		// 执行查询
		ArrayList tRs = tOrderDtlDAO.queryOrderDetailByOpt(aOrderVO, pageNo, pageSize);
		return tRs;
	}

	/**
	 * 运营公司级申购综合查询订单取得总笔数
	 * 
	 * @param aOrderVO
	 *            传入的查询参数VO对象
	 * @param aOrg
	 *            可查询订货单位ArrayList对象
	 * @return
	 * @throws GSException
	 */
	public int getOrderDetailCountByOpt(GSOrderVO aOrderVO) throws GSException {
		String[] tDateStr = new String[2];
		// 取得查询参数订单创建最小日期和最大日期
		tDateStr[0] = aOrderVO.orderCreateDateLowLimie;
		tDateStr[1] = aOrderVO.orderCreateDateUprLimie;
		// 格式化日期
		tDateStr = DateUtil.formateDate(tDateStr);
		aOrderVO.orderCreateDateLowLimie = tDateStr[0];
		aOrderVO.orderCreateDateUprLimie = tDateStr[1];

		GSOrderDetailDAO tOrderDtlDAO = new GSOrderDetailDAO();
		int size = tOrderDtlDAO.queryOrderDetailCountByOpt(aOrderVO);
		return size;
	}

	/**
	 * 采购跟踪查询订单
	 * 
	 * @param aOrderVO
	 *            传入的查询参数VO对象
	 * @param aOrg
	 *            可查询订货单位ArrayList对象
	 * @return
	 * @throws GSException
	 */
	public ArrayList getOrderDetailForStatusTrace(GSOrderVO aOrderVO, int pageNo, int pageSize) throws GSException {
		ArrayList tList = new ArrayList();

		GSOrderDetailDAO tOrderDtlDAO = new GSOrderDetailDAO();
		// 执行查询
		ArrayList tRs = tOrderDtlDAO.queryOrderDetailForStatusTrace(aOrderVO, pageNo, pageSize);
		if (tRs.size() > 0) {
			// 重新封装查询结果
			String tempOrderDetailId = "";
			for (int i = 0; i < tRs.size(); i++) {
				GSOrderAnaDetailBean tOrderQryVO = (GSOrderAnaDetailBean) tRs.get(i);
				if (tempOrderDetailId.equals(tOrderQryVO.getGs_order_detail_id())) {
					continue;
				} else {
					String[] tStr = new String[21];
					tStr[0] = tOrderQryVO.getGs_order_detail_id();
					tStr[1] = tOrderQryVO.getName_product();
					tStr[2] = tOrderQryVO.getSpec();
					tStr[3] = tOrderQryVO.getModel();
					tStr[4] = tOrderQryVO.getProduct_brand();
					tStr[5] = StringUtils.formatEDouble(tOrderQryVO.getGs_order_count(), 2) + tOrderQryVO.getProduct_unit();
					tStr[6] = GSBaseManager.getOrderDetailStatusName(tOrderQryVO.getGs_order_detail_status());
					tStr[7] = tOrderQryVO.getGs_order_create_date();
					tStr[8] = tOrderQryVO.getName_warehouse();
					tStr[9] = GSBaseManager.getDeliverModeName(tOrderQryVO.getGs_deliver_mode());
					tStr[10] = GSBaseManager.getBalanceModeName(tOrderQryVO.getGs_balance_mode_order());
					tStr[11] = tOrderQryVO.getGs_order_tempid_order();
					tStr[12] = tOrderQryVO.getGs_concentricity_id();
					tStr[13] = StringUtils.formatEDouble(tOrderQryVO.getGs_goods_unitprice(), 4);
					tStr[14] = StringUtils.formatEDouble(tOrderQryVO.getGs_goods_unitprice() * tOrderQryVO.getGs_order_count(), 4);
					tStr[15] = tOrderQryVO.getGs_manufacture_id();
					tStr[16] = tOrderQryVO.getCode();
					tStr[17] = tOrderQryVO.getName();
					tStr[18] = tOrderQryVO.getGs_deliver_goods_date();
					tStr[19] = tOrderQryVO.getGs_balance_mode();
					tStr[20] = tOrderQryVO.getDrawing_piece_code();
					tList.add(tStr);
					tempOrderDetailId = tOrderQryVO.getGs_order_detail_id();

				}
			}
		}
		return tList;
	}

	/**
	 * 取得运营公司所有待取消订单及明细信息
	 * 
	 * @param aGSOrderVO
	 *            封装订单查询参数的VO对象
	 * @return
	 * @throws GSException
	 */
	public ArrayList getCancelOrderAndDetail(GSOrderCancelVO aGSOrderCancelVO) throws GSException {
		ArrayList tOrderList = new ArrayList();
		GSOrderDAO tGSOrderDAO = new GSOrderDAO();
		Connection tConn = null;
		try {
			// 取得DB连接
			tConn = tGSOrderDAO.getConnetion();
			String[] tDateStr = new String[2];
			// 取得查询参数订单创建最小日期和最大日期
			tDateStr[0] = aGSOrderCancelVO.orderCreateDateStr;
			tDateStr[1] = aGSOrderCancelVO.orderCreateDateEnd;
			aGSOrderCancelVO.orderCreateDateStr = tDateStr[0];
			aGSOrderCancelVO.orderCreateDateEnd = tDateStr[1];
			// 查询所有订单及明细
			tOrderList = tGSOrderDAO.queryCancelOrder(tConn, aGSOrderCancelVO);
		} catch (GSException ge) {
			throw ge;
		} catch (Exception e) {
			GSLogWriter.debug(this, e.toString());
			throw new GSException(GSException.E10041, GSException.E10041_MSG);
		} finally {
			GSOrderDAO.close(tConn);
		}
		return tOrderList;
	}

	/**
	 * 取消申购信息
	 * 
	 * @param aOrderDetailStatus
	 * @param aOrderDetailId
	 * @return
	 * @throws GSException
	 */
	public static boolean modifyCancelOrderTask(String aOrderDetailStatus, String[] aOrderDetailId, String aOperId, String aOperDate) throws GSException {
		boolean tFlag = false;
		GSOrderDAO tGSOrderDAO = new GSOrderDAO();
		int j = aOrderDetailId.length;
		for (int i = 0; i < j; i++) {
			String tOrderDetailId = aOrderDetailId[i];
			tFlag = tGSOrderDAO.modifyCancelOrder(aOrderDetailStatus, tOrderDetailId, aOperId, aOperDate);
		}
		return tFlag;
	}

	/**
	 * 获取网上订单送货跟踪信息
	 * 
	 * @param aForm
	 * @return 网上订单送货跟踪信息列表
	 * @throws GSException
	 */
	public ArrayList getOrderDeliverStatusList(GSOrderStatusTraceQueryForm aForm, ArrayList aOrg, int pageNo, int pageSize) throws GSException {
		GSOrderDAO tGSOrderDAO = new GSOrderDAO();
		ArrayList tList = new ArrayList();
		Connection tConn = null;
		try {
			// 取得DB连接
			tConn = tGSOrderDAO.getConnetion();

			// 查询所有订单及明细
			tList = tGSOrderDAO.getOrderDeliverStatusList(tConn, aForm, aOrg, pageNo, pageSize);
		} catch (GSException ge) {
			throw ge;
		} catch (Exception e) {
			GSLogWriter.debug(this, e.toString());
			throw new GSException(GSException.E10041, GSException.E10041_MSG);
		} finally {
			GSOrderDAO.close(tConn);
		}
		return tList;
	}

	/**
	 * 巴士物资根据订单编号取得订单明细用于详细显示页面
	 * 
	 * @param aOrderId
	 *            订单编号
	 * @return
	 * @throws GSException
	 */
	public ArrayList getOrderDetailOfBus(String aOrderId) throws GSException {
		ArrayList tRs = new ArrayList();
		GSOrderDetailDAO tOrderDetailDAO = new GSOrderDetailDAO();
		// 查询SQL
		StringBuffer tSql = new StringBuffer("select distinct a.GS_ORDER_DETAIL_ID as P1,a.GS_CONCENTRICITY_ID as P2,");
		tSql.append("b.NAME as P3,b.SPEC as P4,b.model as P5,");
		tSql.append("b.PRODUCT_BRAND as P6,c.name as P7,");
		tSql.append("a.GS_ORDER_COUNT as P8,b.PRODUCT_UNIT as P9,a.GS_GOODS_UNITPRICE as P10,");
		tSql.append("a.GS_DELIVER_GOODS_DATE as P11,a.GS_DELIVER_GOODS_TIME as P12,a.GS_ORDER_DETAIL_STATUS as P13,");
		tSql.append("a.GS_ORDER_TEMPID as P14,b.IS_TRADEFLAT_PRODUCT as P15,c.CODE as P16,");
		tSql.append("c.IS_TRADEFLAT_PROVIDER as P17,b.UNIT_PRICE as P18,b.QUALITY_ASSURE_PERIOD as P19,a.GS_ORDERRETURN_SIGN as P20,b.IS_NORMAL as P21 ");
		tSql.append("from GS_ORDER_DETAIL a,t_product b,t_PROVIDER c ");
		tSql.append("where a.GS_ORDER_TEMPID='" + aOrderId + "' and a.GS_CONCENTRICITY_ID=b.CONCENTRICITY_CODE ");
		tSql.append("and c.code=a.GS_PROVIDER_ID ");
		tSql.append("and a.gs_manufacture_id=b.APEP_CODE ");
		// 执行查询
		ArrayList tList = tOrderDetailDAO.queryOrderDetail(tSql.toString(), new GSOrderDetailOfBusVO());
		if (tList.size() > 0) {
			// 封装查询结果
			for (int i = 0; i < tList.size(); i++) {
				String tStr[] = new String[20];
				GSOrderDetailOfBusVO tVO = (GSOrderDetailOfBusVO) tList.get(i);
				tStr[0] = tVO.orderDetailId;
				tStr[1] = tVO.conCentricityId;
				tStr[2] = tVO.manufactureName;
				tStr[3] = tVO.manufSpec;
				tStr[4] = tVO.manufType;
				tStr[5] = tVO.manufBrand;
				tStr[6] = tVO.providerName;
				tStr[7] = StringUtils.formatEDouble(tVO.orderCount, 2);
				tStr[8] = tVO.quantUnit;
				tStr[9] = StringUtils.formatEDouble(tVO.goodUnitprice, 4);
				tStr[10] = StringUtils.formatEDouble(tVO.goodUnitprice * tVO.orderCount, 4);
				tStr[11] = tVO.deliverGoodsDate;
				System.out.print(tVO.deliverGoodsTime);
				tStr[12] = GSBaseManager.getDeliverGoodsTime(tVO.deliverGoodsTime);
				tStr[13] = GSBaseManager.getOrderDetailStatusName(tVO.orderDetailStatus);
				tStr[14] = tVO.providerId;
				tStr[15] = tVO.isTradeFlatManuf;
				tStr[16] = tVO.isTradeFlatProvider;
				tStr[17] = tVO.orderDetailStatus;
				// tStr[18] = StringUtils.formatEDouble(tVO.manufUnitprice,4);
				tStr[18] = tVO.qualityAssurePeriod;
				tStr[19] = tVO.sign;
				tRs.add(tStr);
			}
		}
		return tRs;
	}

	/**
	 * 巴士物资查询执行详细查询
	 * 
	 * @param aOrderId
	 *            订单编号
	 * @return
	 * @throws GSException
	 */
	public ArrayList getOrderDetailOfBusQry(String aOrderId) throws GSException {
		ArrayList tRs = new ArrayList();
		GSOrderDetailDAO tOrderDetailDAO = new GSOrderDetailDAO();
		// 查询SQL
		StringBuffer tSql = new StringBuffer("select distinct a.GS_ORDER_DETAIL_ID as P1,a.GS_CONCENTRICITY_ID as P2,");
		tSql.append("b.NAME as P3,b.SPEC as P4,b.MODEL as P5,");
		tSql.append("b.PRODUCT_BRAND as P6,c.NAME as P7,a.GS_ORDER_COUNT as P8,");
		tSql.append("b.PRODUCT_UNIT as P9,a.GS_GOODS_UNITPRICE as P10,a.GS_DELIVER_GOODS_DATE as P11,");
		tSql.append("a.GS_DELIVER_GOODS_TIME as P12,a.GS_ORDER_DETAIL_STATUS as P13,a.GS_ORDER_TEMPID as P14,");
		tSql.append("b.IS_TRADEFLAT_PRODUCT as P15,c.CODE as P16,a.GS_DELIVER_GOODS_ID as P17,");
		tSql.append("a.GS_DELIVERYMAN as P18,a.GS_DELIVER_GOODS_PHONE as P19,a.GS_DELIVER_GOODS_COUNTS as P20,");
		tSql.append("a.GS_DELIVER_GOODS_CONFIRM_DATE as P21,a.GS_DELIVER_GOODS_CONFIRM_TIME as P22,");
		tSql.append("a.GS_SIGNIN_DATE as P23,a.GS_SIGNIN_COUNT as P24,a.GS_SIGNIN_PERSON as P25,");
		tSql.append("c.IS_TRADEFLAT_PROVIDER as P26,a.GS_AUTHORIZE_ADVICES as P27,");
		tSql.append("a.GS_AUTHORIZER_ID as P28,a.GS_AUTHORIZE_DATE as P29,a.GS_CANCEL_CAUSE as P30,");
		tSql.append("a.GS_CANCEL_PERSON as P31,a.GS_CANCEL_DATE as P32,a.GS_REJECT_CAUSE as P33,");
		tSql.append("a.GS_REJECT_DATE as P34,a.GS_REJECT_TIME as P35, ");
		tSql.append("a.DISPOSE_CANCEL_REASON as P36,a.DISPOSE_CANCEL_PERSON as P37, ");
		tSql.append("a.DISPOSE_CANCEL_TIME as P38 ");
		tSql.append("from GS_ORDER_DETAIL a,t_product b,T_PROVIDER c ");
		tSql.append("where a.GS_ORDER_TEMPID='" + aOrderId + "' and a.GS_CONCENTRICITY_ID=b.CONCENTRICITY_CODE ");
		tSql.append("and c.CODE=a.GS_PROVIDER_ID ");
		tSql.append("and a.gs_manufacture_id=b.APEP_CODE ");
		// 执行查询
		ArrayList tList = tOrderDetailDAO.queryOrderDetail(tSql.toString(), new GSOrderDetailOfBusQryVO());
		if (tList.size() > 0) {
			// 封装查询结果
			for (int i = 0; i < tList.size(); i++) {
				String tStr[] = new String[37];
				GSOrderDetailOfBusQryVO tVO = (GSOrderDetailOfBusQryVO) tList.get(i);
				tStr[0] = tVO.orderDetailId;
				tStr[1] = tVO.conCentricityId;
				tStr[2] = tVO.manufactureName;
				tStr[3] = tVO.manufSpec;
				tStr[4] = tVO.manufType;
				tStr[5] = tVO.manufBrand;
				tStr[6] = tVO.providerName;
				tStr[7] = StringUtils.formatEDouble(tVO.orderCount, 2);
				tStr[8] = tVO.quantUnit;
				tStr[9] = StringUtils.formatEDouble(tVO.goodUnitprice, 4);
				tStr[10] = StringUtils.formatEDouble(tVO.goodUnitprice * tVO.orderCount, 4);
				tStr[11] = tVO.deliverGoodsDate;
				System.out.print(tVO.deliverGoodsTime);
				if (tVO.deliverGoodsTime == null) {
					tStr[12] = tVO.deliverGoodsTime;
				} else {
					tStr[12] = GSBaseManager.getDeliverGoodsTime(tVO.deliverGoodsTime);
				}
				tStr[13] = tVO.orderDetailStatus;
				tStr[14] = tVO.providerId;
				tStr[15] = tVO.isTradeFlatManuf;
				tStr[16] = tVO.deliverGoodsId;
				tStr[17] = tVO.deliverGoodsConfDate + " " + tVO.deliverGoodsConfTime;
				tStr[18] = tVO.deliverMan;
				tStr[19] = tVO.deliverGoodsPhone;
				tStr[20] = StringUtils.formatEDouble(tVO.deliverGoodsCount, 2);
				tStr[21] = tVO.signDate;
				tStr[22] = tVO.signPerson;
				tStr[23] = StringUtils.formatEDouble(tVO.signCount, 2);
				tStr[24] = tVO.isTradeFlatProvider;
				tStr[25] = tVO.authorizeadvice;
				tStr[26] = tVO.authorizeid;
				tStr[27] = tVO.authorizedate;
				tStr[28] = tVO.cancelcause;
				tStr[29] = tVO.cancelperson;
				tStr[30] = tVO.canceldate;
				tStr[31] = tVO.rejectcause;
				tStr[32] = tVO.rejectdate;
				tStr[33] = tVO.rejecttime;

				tStr[34] = tVO.disposeCancelReason;
				tStr[35] = tVO.disposeCancelPerson;
				tStr[36] = tVO.disposeCancelTime;

				tRs.add(tStr);
			}
		}
		return tRs;
	}
	
	/**
	 * 巴士物资查询执行详细查询
	 * 
	 * @param aOrderId
	 *            订单编号
	 * @return
	 * @throws GSException
	 */
	public ArrayList getOrderDetailOfBusQryNew(String aOrderId) throws GSException {
		ArrayList tRs = new ArrayList();
		GSOrderDetailDAO tOrderDetailDAO = new GSOrderDetailDAO();
		// 查询SQL
		StringBuffer tSql = new StringBuffer("select distinct a.GS_ORDER_DETAIL_ID as P1,a.GS_CONCENTRICITY_ID as P2,");
		tSql.append("b.NAME as P3,b.SPEC as P4,b.MODEL as P5,");
		tSql.append("b.PRODUCT_BRAND as P6,c.NAME as P7,a.GS_ORDER_COUNT as P8,");
		tSql.append("b.PRODUCT_UNIT as P9,a.GS_GOODS_UNITPRICE as P10,a.GS_DELIVER_GOODS_DATE as P11,");
		tSql.append("a.GS_DELIVER_GOODS_TIME as P12,a.GS_ORDER_DETAIL_STATUS as P13,a.GS_ORDER_TEMPID as P14,");
		tSql.append("b.IS_TRADEFLAT_PRODUCT as P15,c.CODE as P16,a.GS_DELIVER_GOODS_ID as P17,");
		tSql.append("a.GS_DELIVERYMAN as P18,a.GS_DELIVER_GOODS_PHONE as P19,a.GS_DELIVER_GOODS_COUNTS as P20,");
		tSql.append("a.GS_DELIVER_GOODS_CONFIRM_DATE as P21,a.GS_DELIVER_GOODS_CONFIRM_TIME as P22,");
		tSql.append("a.GS_SIGNIN_DATE as P23,a.GS_SIGNIN_COUNT as P24,a.GS_SIGNIN_PERSON as P25,");
		tSql.append("c.IS_TRADEFLAT_PROVIDER as P26,a.GS_AUTHORIZE_ADVICES as P27,");
		tSql.append("a.GS_AUTHORIZER_ID as P28,a.GS_AUTHORIZE_DATE as P29,a.GS_CANCEL_CAUSE as P30,");
		tSql.append("a.GS_CANCEL_PERSON as P31,a.GS_CANCEL_DATE as P32,a.GS_REJECT_CAUSE as P33,");
		tSql.append("a.GS_REJECT_DATE as P34,a.GS_REJECT_TIME as P35, ");
		tSql.append("a.DISPOSE_CANCEL_REASON as P36,a.DISPOSE_CANCEL_PERSON as P37, ");
		tSql.append("a.DISPOSE_CANCEL_TIME as P38 ");
		tSql.append("from GS_ORDER_DETAIL a,t_product b,T_PROVIDER c ");
		tSql.append("where a.GS_ORDER_TEMPID='" + aOrderId + "' and a.GS_CONCENTRICITY_ID=b.CONCENTRICITY_CODE ");
		tSql.append(" and a.GS_PROVIDER_ID = '90001' and c.CODE=a.GS_PROVIDER_ID ");
		tSql.append(" and (a.GS_ORDER_DETAIL_STATUS in ('3','10','11','12')) ");
		tSql.append("and a.gs_manufacture_id=b.APEP_CODE ");
		// 执行查询
		ArrayList tList = tOrderDetailDAO.queryOrderDetail(tSql.toString(), new GSOrderDetailOfBusQryVO());
		if (tList.size() > 0) {
			// 封装查询结果
			for (int i = 0; i < tList.size(); i++) {
				String tStr[] = new String[37];
				GSOrderDetailOfBusQryVO tVO = (GSOrderDetailOfBusQryVO) tList.get(i);
				tStr[0] = tVO.orderDetailId;
				tStr[1] = tVO.conCentricityId;
				tStr[2] = tVO.manufactureName;
				tStr[3] = tVO.manufSpec;
				tStr[4] = tVO.manufType;
				tStr[5] = tVO.manufBrand;
				tStr[6] = tVO.providerName;
				tStr[7] = StringUtils.formatEDouble(tVO.orderCount, 2);
				tStr[8] = tVO.quantUnit;
				tStr[9] = StringUtils.formatEDouble(tVO.goodUnitprice, 4);
				tStr[10] = StringUtils.formatEDouble(tVO.goodUnitprice * tVO.orderCount, 4);
				tStr[11] = tVO.deliverGoodsDate;
				System.out.print(tVO.deliverGoodsTime);
				if (tVO.deliverGoodsTime == null) {
					tStr[12] = tVO.deliverGoodsTime;
				} else {
					tStr[12] = GSBaseManager.getDeliverGoodsTime(tVO.deliverGoodsTime);
				}
				tStr[13] = tVO.orderDetailStatus;
				tStr[14] = tVO.providerId;
				tStr[15] = tVO.isTradeFlatManuf;
				tStr[16] = tVO.deliverGoodsId;
				tStr[17] = tVO.deliverGoodsConfDate + " " + tVO.deliverGoodsConfTime;
				tStr[18] = tVO.deliverMan;
				tStr[19] = tVO.deliverGoodsPhone;
				tStr[20] = StringUtils.formatEDouble(tVO.deliverGoodsCount, 2);
				tStr[21] = tVO.signDate;
				tStr[22] = tVO.signPerson;
				tStr[23] = StringUtils.formatEDouble(tVO.signCount, 2);
				tStr[24] = tVO.isTradeFlatProvider;
				tStr[25] = tVO.authorizeadvice;
				tStr[26] = tVO.authorizeid;
				tStr[27] = tVO.authorizedate;
				tStr[28] = tVO.cancelcause;
				tStr[29] = tVO.cancelperson;
				tStr[30] = tVO.canceldate;
				tStr[31] = tVO.rejectcause;
				tStr[32] = tVO.rejectdate;
				tStr[33] = tVO.rejecttime;

				tStr[34] = tVO.disposeCancelReason;
				tStr[35] = tVO.disposeCancelPerson;
				tStr[36] = tVO.disposeCancelTime;

				tRs.add(tStr);
			}
		}
		return tRs;
	}

	/**
	 * 取得物资公司所有待取消订单及明细信息
	 * 
	 * @param aGSOrderVO
	 *            封装订单查询参数的VO对象
	 * @return
	 * @throws GSException
	 */
	public ArrayList getBusCancelOrderAndDetail(GSBusOrderCancelVO aGSBusOrderCancelVO) throws GSException {
		ArrayList tBusOrderList = new ArrayList();
		GSBusOrderDAO tGSBusOrderDAO = new GSBusOrderDAO();
		ArrayList tList = new ArrayList();
		Connection tConn = null;
		try {
			// 取得DB连接
			tConn = tGSBusOrderDAO.getConnetion();
			String[] tDateStr = new String[2];
			// 取得查询参数订单创建最小日期和最大日期
			tDateStr[0] = aGSBusOrderCancelVO.orderCreateDateStr;
			tDateStr[1] = aGSBusOrderCancelVO.orderCreateDateEnd;
			// 格式化日期
			tDateStr = DateUtil.formateDate(tDateStr);
			aGSBusOrderCancelVO.orderCreateDateStr = tDateStr[0];
			aGSBusOrderCancelVO.orderCreateDateEnd = tDateStr[1];
			// 查询所有订单及明细
			tBusOrderList = tGSBusOrderDAO.queryBusCancelOrder(tConn, aGSBusOrderCancelVO);
			if (tBusOrderList.size() > 0) {

				for (int i = 0; i < tBusOrderList.size(); i++) {

					GSOrderAnaDetailAndCategoryBean tGSBusOrderCancelOfWorkingVO = (GSOrderAnaDetailAndCategoryBean) tBusOrderList.get(i);

					String[] tStr = new String[24];
					tStr[0] = tGSBusOrderCancelOfWorkingVO.getGs_order_detail_id();
					tStr[1] = GSBaseManager.getOrderDetailStatusName(tGSBusOrderCancelOfWorkingVO.getGs_order_detail_status());
					tStr[2] = tGSBusOrderCancelOfWorkingVO.getGs_concentricity_id();
					tStr[3] = tGSBusOrderCancelOfWorkingVO.getName_product();
					tStr[4] = GSBaseManager.getTradeflatName(tGSBusOrderCancelOfWorkingVO.getIs_tradeflat_product());
					tStr[5] = tGSBusOrderCancelOfWorkingVO.getSpec();
					tStr[6] = tGSBusOrderCancelOfWorkingVO.getModel();
					tStr[7] = tGSBusOrderCancelOfWorkingVO.getProduct_brand();
					tStr[8] = tGSBusOrderCancelOfWorkingVO.getName();
					tStr[9] = StringUtils.formatEDouble(tGSBusOrderCancelOfWorkingVO.getGs_order_count(), 2);
					tStr[10] = tGSBusOrderCancelOfWorkingVO.getProduct_unit();
					tStr[11] = StringUtils.formatEDouble(tGSBusOrderCancelOfWorkingVO.getGs_goods_unitprice(), 4);
					tStr[12] = tGSBusOrderCancelOfWorkingVO.getName_warehouse();
					tStr[13] = tGSBusOrderCancelOfWorkingVO.getGs_deliver_goods_confirm_date();
					tStr[14] = GSBaseManager.getDeliverGoodsTime(tGSBusOrderCancelOfWorkingVO.getGs_deliver_goods_confirm_time());
					tStr[15] = StringUtils.formatEDouble(tGSBusOrderCancelOfWorkingVO.getGs_goods_unitprice()
							* tGSBusOrderCancelOfWorkingVO.getGs_order_count(), 4);
					tStr[16] = tGSBusOrderCancelOfWorkingVO.getCode();
					tStr[17] = tGSBusOrderCancelOfWorkingVO.getIs_tradeflat_provider();
					tStr[18] = tGSBusOrderCancelOfWorkingVO.getGs_order_tempid_order();
					tStr[19] = tGSBusOrderCancelOfWorkingVO.getCode();
					tStr[20] = tGSBusOrderCancelOfWorkingVO.getIs_tradeflat_provider();
					tStr[21] = tGSBusOrderCancelOfWorkingVO.getGs_balance_mode();
					tStr[22] = GSBaseManager.getProductTypeByCode(tGSBusOrderCancelOfWorkingVO.getIs_normal());
					tStr[23] = tGSBusOrderCancelOfWorkingVO.getDrawing_piece_code();
					tList.add(tStr);
				}
			}
		} catch (GSException ge) {
			throw ge;
		} catch (Exception e) {
			GSLogWriter.debug(this, e.toString());
			throw new GSException(GSException.E10041, GSException.E10041_MSG);
		} finally {
			GSBusOrderDAO.close(tConn);
		}
		return tList;
	}

	/**
	 * 取消巴士物资订单信息
	 * 
	 * @param aOrderDetailStatus
	 * @param aOrderDetailId
	 * @return
	 * @throws GSException
	 */
	public static boolean modifyCancelBusOrderTask(String aOldStatus, String aOrderDetailStatus, String aOrderDetailId, LoginContext context, String aOperDate,
			String aContents, String aIsTradeFlatManuf, String aIsTradeFlatProv, String sign) throws GSException {

		boolean tFlag = false;
		GSBusOrderDAO tGSBusOrderDAO = new GSBusOrderDAO();
		Connection tConn = null;
		try {
			tConn = tGSBusOrderDAO.getConnetion();
			tConn.setAutoCommit(false);
			tFlag = tGSBusOrderDAO.modifyCancelBusOrder(tConn, aOrderDetailStatus, aOrderDetailId, context, aOperDate, aContents);
			if (tFlag) {
				if ((aOldStatus.equals(GSBaseConstants.ORDER_ORDERING) || aOldStatus.equals(GSBaseConstants.ORDER_ORDER_CONFIRM) || aOldStatus
						.equals(GSBaseConstants.ORDER_ORDER_REJECT))
						&& sign.equals(GSBaseConstants.APEP_RETURN_SIGN_SUCCESS)) {
					// 发送订单信息到采购网
					String tRs = GSCommunicationApepProcessor.cancelOrderDetailApep(aOrderDetailId, aContents, context);
					String[] result = GSCommunicationApepProcessor.parseReturnXml(tRs);
					// 判断返回结果
					if (result[0].equals(GSBaseConstants.APEP_RETURN_SIGN_SUCCESS)) {
						tConn.commit();
						GSLogWriter.debug("提交返回成功");
					} else {
						tConn.rollback();
						GSLogWriter.error("提交返回失败");
						tFlag = false;
					}
				} else {
					GSLogWriter.info("不需要向交易平台提交订单取消信息，直接修改DB中订单明细状态");
					tConn.commit();
				}
			} else {
				GSLogWriter.error("修改订单状态为取消时失败");
			}
		} catch (GSException ge) {
			try {
				if (tConn != null) {
					tConn.rollback();
				}
			} catch (SQLException se) {
				se.printStackTrace();
			}
			throw ge;
		} catch (Exception e) {
			try {
				if (tConn != null) {
					tConn.rollback();
				}
			} catch (SQLException se) {
				se.printStackTrace();
			}
			GSLogWriter.error(e.toString());
			throw new GSException(GSException.E10066, GSException.E10066_MSG);
		} finally {
			GSBusOrderDAO.close(tConn);
		}
		return tFlag;
	}

	/**
	 * 获取网上订单收货跟踪信息
	 * 
	 * @param aForm
	 * @return 网上订单收货跟踪信息列表
	 * @throws GSException
	 */
	public ArrayList getOrderReceiveStatusList(GSOrderStatusTraceQueryForm aForm, ArrayList aOrg, int pageNo, int pageSize) throws GSException {
		GSOrderDAO tGSOrderDAO = new GSOrderDAO();
		ArrayList tList = new ArrayList();
		Connection tConn = null;
		try {
			// 取得DB连接
			tConn = tGSOrderDAO.getConnetion();
			// 查询所有订单及明细
			tList = tGSOrderDAO.getOrderReceiveStatusList(tConn, aForm, aOrg, pageNo, pageSize);
		} catch (GSException ge) {
			throw ge;
		} catch (Exception e) {
			GSLogWriter.debug(this, e.toString());
			throw new GSException(GSException.E10041, GSException.E10041_MSG);
		} finally {
			GSOrderDAO.close(tConn);
		}
		return tList;
	}

	/**
	 * 获取订单查询信息
	 * 
	 * @param aForm
	 * @return 订单查询信息列表
	 * @throws GSException
	 */
	public ArrayList getOrderDetailList(GSOrderDetailQueryForm aForm, int pageNo, int pageSize) throws GSException {
		GSOrderDAO tGSOrderDAO = new GSOrderDAO();
		ArrayList tList = new ArrayList();
		Connection tConn = null;
		try {
			// 取得DB连接
			tConn = tGSOrderDAO.getConnetion();

			// 查询所有订单及明细
			tList = tGSOrderDAO.getOrderDetailList(tConn, aForm, pageNo, pageSize);
		} catch (GSException ge) {
			throw ge;
		} catch (Exception e) {
			GSLogWriter.debug(this, e.toString());
			throw new GSException(GSException.E10041, GSException.E10041_MSG);
		} finally {
			GSOrderDAO.close(tConn);
		}
		return tList;
	}

	/**
	 * 获取所查询订单的总金额
	 * @author wp
	 * 2010-03-26
	 */
	public double getOrderDetailTotalAmount(GSOrderDetailQueryForm aForm) throws GSException {
		GSOrderDAO tGSOrderDAO = new GSOrderDAO();
		double totalAmount = 0d;
		Connection tConn = null;
		try {
			// 取得DB连接
			tConn = tGSOrderDAO.getConnetion();

			// 查询所有订单及明细
			totalAmount = tGSOrderDAO.getOrderDetailTotalAmount(tConn, aForm);
		} catch (GSException ge) {
			throw ge;
		} catch (Exception e) {
			GSLogWriter.debug(this, e.toString());
			throw new GSException(GSException.E10041, GSException.E10041_MSG);
		} finally {
			GSOrderDAO.close(tConn);
		}
		return totalAmount;
	}

	/**
	 * 获取申沃订单查询信息
	 * 
	 * @param aForm
	 * @return 订单查询信息列表
	 * @throws GSException
	 */
	public ArrayList getOrderDetailListForSW(GSOrderDetailQueryForm aForm, int pageNo, int pageSize) throws GSException {
		GSOrderDAO tGSOrderDAO = new GSOrderDAO();
		ArrayList tList = new ArrayList();
		Connection tConn = null;
		try {
			// 取得DB连接
			tConn = tGSOrderDAO.getConnetion();

			// 查询所有订单及明细
			tList = tGSOrderDAO.getOrderDetailListForSW(tConn, aForm, pageNo, pageSize);
		} catch (GSException ge) {
			throw ge;
		} catch (Exception e) {
			GSLogWriter.debug(this, e.toString());
			throw new GSException(GSException.E10041, GSException.E10041_MSG);
		} finally {
			GSOrderDAO.close(tConn);
		}
		return tList;
	}
	
	/**
	 * 获取申沃订单查询信息 主表汇总信息 
	 * 
	 * @param aForm
	 * @return 订单查询信息列表
	 * @throws GSException
	 */
	public ArrayList getOrderDetailListForSWNew(GSOrderDetailQueryForm aForm, int pageNo, int pageSize) throws GSException {
		GSOrderDAO tGSOrderDAO = new GSOrderDAO();
		ArrayList tList = new ArrayList();
		Connection tConn = null;
		try {
			// 取得DB连接
			tConn = tGSOrderDAO.getConnetion();

			// 查询所有订单及明细
			tList = tGSOrderDAO.getOrderDetailListForSWNew(tConn, aForm, pageNo, pageSize);
		} catch (GSException ge) {
			throw ge;
		} catch (Exception e) {
			GSLogWriter.debug(this, e.toString());
			throw new GSException(GSException.E10041, GSException.E10041_MSG);
		} finally {
			GSOrderDAO.close(tConn);
		}
		return tList;
	}

	/**
	 * 取得待结算审核订单明细
	 * 
	 * @param aForm
	 * @param aOrg
	 * @param pageNo
	 * @param pageSize
	 * @return
	 * @throws GSException
	 */
	public ArrayList getOrderDetailListForBalanceAudit(GSOrderDetailQueryForm aForm, ArrayList aOrg, int pageNo, int pageSize) throws GSException {
		GSOrderDAO tGSOrderDAO = new GSOrderDAO();
		GSProviderDAO tGSProviderDAO = new GSProviderDAO();
		ArrayList tList = new ArrayList();
		Connection tConn = null;
		try {
			// 取得DB连接
			tConn = tGSOrderDAO.getConnetion();

			// 查询所有订单及明细
			tList = tGSOrderDAO.getOrderDetailListForBalanceAudit(tConn, aForm, aOrg, pageNo, pageSize);
			String cczxId = "";
			String cczxName = "";
			if (tList.size() > 0) {
				cczxId = GSSystemConfigurator.getParam("gs.provider.cczxid");
				cczxName = tGSProviderDAO.queryProvider(cczxId).getGs_provider_shortname();
			}
			for (int i = 0; i < tList.size(); i++) {
				GSOrderDetailQueryVO tVO = (GSOrderDetailQueryVO) tList.get(i);
				if ("0".equals(tVO.isTradeFlatManufacture)) {
					tVO.providerId = cczxId;
					tVO.providerName = cczxName;
				}
			}
		} catch (GSException ge) {
			throw ge;
		} catch (Exception e) {
			GSLogWriter.debug(this, e.toString());
			throw new GSException(GSException.E10041, GSException.E10041_MSG);
		} finally {
			GSOrderDAO.close(tConn);
		}
		return tList;
	}

	/**
	 * 取得非网上待签收订单明细
	 * 
	 * @param aOrderId
	 *            订单编码
	 * @param aOrderDetailId
	 *            订单明细编码
	 * @return
	 * @throws GSException
	 */
	public ArrayList getOrderDetailForRecordSignInfo(String aOrderId, String aOrderDetailId) throws GSException {
		ArrayList tRs = new ArrayList();
		GSOrderDetailDAO tOrderDetailDAO = new GSOrderDetailDAO();
		// 查询SQL
		StringBuffer tSql = new StringBuffer("select distinct a.GS_ORDER_DETAIL_ID as P1,a.GS_CONCENTRICITY_ID as P2,");
		tSql.append("b.NAME as P3,b.SPEC as P4,b.MODEL as P5,");
		tSql.append("b.PRODUCT_BRAND as P6,c.NAME as P7,");
		tSql.append("a.GS_ORDER_COUNT as P8,b.PRODUCT_UNIT as P9,a.GS_GOODS_UNITPRICE as P10,");
		tSql.append("a.GS_DELIVER_GOODS_DATE as P11,a.GS_DELIVER_GOODS_TIME as P12,a.GS_ORDER_DETAIL_STATUS as P13,");
		tSql.append("a.GS_ORDER_TEMPID as P14,b.IS_TRADEFLAT_PRODUCT as P15,c.code as P16,");
		tSql.append("c.IS_TRADEFLAT_PROVIDER as P17,b.UNIT_PRICE as P18,b.QUALITY_ASSURE_PERIOD as P19,a.gs_orderreturn_sign as P20,b.IS_NORMAL as P21 ");
		tSql.append("from GS_ORDER_DETAIL a,t_product b,t_PROVIDER c ");
		tSql.append("where a.GS_ORDER_TEMPID='" + aOrderId + "' and a.GS_ORDER_DETAIL_ID = '" + aOrderDetailId + "' ");
		tSql.append("and a.GS_CONCENTRICITY_ID=b.CONCENTRICITY_CODE  and c.code=a.GS_PROVIDER_ID ");
		tSql.append("and a.gs_manufacture_id=b.apep_code ");
		// 执行查询
		ArrayList tList = tOrderDetailDAO.queryOrderDetail(tSql.toString(), new GSOrderDetailOfBusVO());
		if (tList.size() > 0) {
			// 封装查询结果
			for (int i = 0; i < tList.size(); i++) {
				String tStr[] = new String[19];
				GSOrderDetailOfBusVO tVO = (GSOrderDetailOfBusVO) tList.get(i);
				tStr[0] = tVO.orderDetailId;
				tStr[1] = tVO.conCentricityId;
				tStr[2] = tVO.manufactureName;
				tStr[3] = tVO.manufSpec;
				tStr[4] = tVO.manufType;
				tStr[5] = tVO.manufBrand;
				tStr[6] = tVO.providerName;
				tStr[7] = StringUtils.formatEDouble(tVO.orderCount, 2);
				tStr[8] = tVO.quantUnit;
				tStr[9] = StringUtils.formatEDouble(tVO.goodUnitprice, 4);
				tStr[10] = StringUtils.formatEDouble(tVO.goodUnitprice * tVO.orderCount, 4);
				tStr[11] = tVO.deliverGoodsDate;
				tStr[12] = GSBaseManager.getDeliverGoodsTime(tVO.deliverGoodsTime);
				tStr[13] = GSBaseManager.getOrderDetailStatusName(tVO.orderDetailStatus);
				tStr[14] = tVO.providerId;
				tStr[15] = tVO.isTradeFlatManuf;
				tStr[16] = tVO.isTradeFlatProvider;
				tStr[17] = StringUtils.formatEDouble(tVO.manufUnitprice, 4);
				tStr[18] = GSBaseManager.getProductTypeByCode(tVO.isnormal);
				tRs.add(tStr);
			}
		}
		return tRs;
	}

	/**
	 * 通过订单明细ID得到订单明细详细信息
	 * 
	 * @param aOrderDetailIds
	 * @return
	 * @throws GSException
	 * @author wp
	 */
	public ArrayList getOrderDetailForSign(String[] aOrderDetailIds) throws GSException {
		ArrayList tRs = new ArrayList();
		GSOrderDetailDAO tOrderDetailDAO = new GSOrderDetailDAO();
		// 查询SQL
		StringBuffer tSql = new StringBuffer("select distinct a.GS_ORDER_DETAIL_ID as P1,a.GS_CONCENTRICITY_ID as P2,");
		tSql.append("b.NAME as P3,b.SPEC as P4,b.MODEL as P5,");
		tSql.append("b.product_BRAND as P6,c.NAME as P7,");
		tSql.append("a.GS_ORDER_COUNT as P8,b.product_unit as P9,a.GS_GOODS_UNITPRICE as P10,");
		tSql.append("a.GS_DELIVER_GOODS_DATE as P11,a.GS_DELIVER_GOODS_TIME as P12,a.GS_ORDER_DETAIL_STATUS as P13,");
		tSql.append("a.GS_ORDER_TEMPID as P14,b.IS_TRADEFLAT_product as P15,c.code as P16,");
		tSql.append("c.IS_TRADEFLAT_PROVIDER as P17,b.UNIT_PRICE as P18,b.quality_assure_period as P19, b.DRAWING_PIECE_CODE As P20, ");
		tSql.append("d.GS_DELIVER_GOODS_ADDR P21,a.Gs_Signin_Count P22  ");
		tSql.append("from GS_ORDER_DETAIL a,t_product b,t_PROVIDER c,GS_ORDER d ");
		tSql.append("where ");
		tSql.append("a.GS_CONCENTRICITY_ID=b.CONCENTRICITY_code  and c.code=a.GS_PROVIDER_ID and a.GS_ORDER_TEMPID = d.GS_ORDER_TEMPID ");
		tSql.append("and a.gs_manufacture_id=b.apep_code ");

		tSql.append(" and a.GS_ORDER_DETAIL_ID in (");
		for (int i = 0; i < aOrderDetailIds.length; i++) {
			if (i != 0) {
				tSql.append(",");
			}
			tSql.append("'").append(aOrderDetailIds[i]).append("'");
			if (i == aOrderDetailIds.length - 1) {
				tSql.append(")");
			}
		}
		// 执行查询
		ArrayList tList = tOrderDetailDAO.queryOrderDetail(tSql.toString(), new GSOrderDetailOfBusForSWVO());
		if (tList.size() > 0) {
			// 封装查询结果
			for (int i = 0; i < tList.size(); i++) {
				String tStr[] = new String[20];
				GSOrderDetailOfBusForSWVO tVO = (GSOrderDetailOfBusForSWVO) tList.get(i);
				tStr[0] = tVO.orderDetailId;
				tStr[1] = tVO.conCentricityId;
				tStr[2] = tVO.manufactureName;
				tStr[3] = tVO.manufSpec;
				tStr[4] = tVO.manufType;
				tStr[5] = tVO.manufBrand;
				tStr[6] = tVO.providerName;
				tStr[7] = StringUtils.formatEDouble(tVO.orderCount, 2);
				tStr[8] = tVO.quantUnit;
				tStr[9] = StringUtils.formatEDouble(tVO.goodUnitprice, 4);
				tStr[10] = StringUtils.formatEDouble(tVO.goodUnitprice * tVO.orderCount, 4);
				tStr[11] = tVO.deliverGoodsDate;
				tStr[12] = tVO.deliverGoodsTime == null ? "" : GSBaseManager.getDeliverGoodsTime(tVO.deliverGoodsTime);
				tStr[13] = GSBaseManager.getOrderDetailStatusName(tVO.orderDetailStatus);
				tStr[14] = tVO.providerId;
				tStr[15] = tVO.isTradeFlatManuf;
				tStr[16] = tVO.isTradeFlatProvider;
				tStr[17] = StringUtils.formatEDouble(tVO.manufUnitprice, 4);
				tStr[18] = tVO.drawingPieceCode;
				tStr[19] = tVO.deliverGoodsAddr;
				tRs.add(tStr);
			}
		}
		return tRs;
	}
	
	
	/**
	 * 通过订单明细ID得到订单明细详细信息
	 * 
	 * @param aOrderDetailIds
	 * @return
	 * @throws GSException
	 * @author wp
	 */
	public ArrayList getOrderDetailForSignNew(String[] aOrderDetailIds) throws GSException {
		ArrayList tRs = new ArrayList();
		GSOrderDetailDAO tOrderDetailDAO = new GSOrderDetailDAO();
		GSOrderDAO orderDao=new GSOrderDAO();
		// 查询SQL
		StringBuffer tSql = new StringBuffer("select distinct a.GS_ORDER_DETAIL_ID as P1,a.GS_CONCENTRICITY_ID as P2,");
		tSql.append("b.NAME as P3,b.SPEC as P4,b.MODEL as P5,");
		tSql.append("b.product_BRAND as P6,c.NAME as P7,");
		tSql.append("a.GS_ORDER_COUNT as P8,b.product_unit as P9,a.GS_GOODS_UNITPRICE as P10,");
		tSql.append("a.GS_DELIVER_GOODS_DATE as P11,a.GS_DELIVER_GOODS_TIME as P12,a.GS_ORDER_DETAIL_STATUS as P13,");
		tSql.append("a.GS_ORDER_TEMPID as P14,b.IS_TRADEFLAT_product as P15,c.code as P16,");
		tSql.append("c.IS_TRADEFLAT_PROVIDER as P17,b.UNIT_PRICE as P18,b.quality_assure_period as P19, b.DRAWING_PIECE_CODE As P20, ");
		tSql.append("d.GS_DELIVER_GOODS_ADDR P21,a.Gs_Signin_Count P22, e.name P23,e.CONTACT_PERSON P24,e.CONTACK_TEL P25 ");
		tSql.append("from GS_ORDER_DETAIL a,t_product b,t_PROVIDER c,GS_ORDER d,t_warehouse e ");
		tSql.append("where ");
		tSql.append("a.GS_CONCENTRICITY_ID=b.CONCENTRICITY_code  and c.code=a.GS_PROVIDER_ID and a.GS_ORDER_TEMPID = d.GS_ORDER_TEMPID ");
		tSql.append("and a.gs_manufacture_id=b.apep_code and d.GS_WORKCORP_ID=e.code ");

		tSql.append(" and a.GS_ORDER_DETAIL_ID in (");
		for (int i = 0; i < aOrderDetailIds.length; i++) {
			if (i != 0) {
				tSql.append(",");
			}
			tSql.append("'").append(aOrderDetailIds[i]).append("'");
			if (i == aOrderDetailIds.length - 1) {
				tSql.append(")");
			}
		}
		// 执行查询
		ArrayList tList = tOrderDetailDAO.queryOrderDetail(tSql.toString(), new GSOrderDetailOfBusForSWVO());
		if (tList.size() > 0) {
			// 封装查询结果
			for (int i = 0; i < tList.size(); i++) {
				String tStr[] = new String[25];
				GSOrderDetailOfBusForSWVO tVO = (GSOrderDetailOfBusForSWVO) tList.get(i);
				tStr[0] = tVO.orderDetailId;
				tStr[1] = tVO.conCentricityId;
				tStr[2] = tVO.manufactureName;
				tStr[3] = tVO.manufSpec;
				tStr[4] = tVO.manufType;
				tStr[5] = tVO.manufBrand;
				tStr[6] = tVO.providerName;
				tStr[7] = StringUtils.formatEDouble(tVO.orderCount, 2);
				tStr[8] = tVO.quantUnit;
				tStr[9] = StringUtils.formatEDouble(tVO.goodUnitprice, 4);
				tStr[10] = StringUtils.formatEDouble(tVO.goodUnitprice * tVO.orderCount, 4);
				tStr[11] = tVO.deliverGoodsDate;
				tStr[12] = tVO.deliverGoodsTime == null ? "" : GSBaseManager.getDeliverGoodsTime(tVO.deliverGoodsTime);
				tStr[13] = GSBaseManager.getOrderDetailStatusName(tVO.orderDetailStatus);
				tStr[14] = tVO.providerId;
				tStr[15] = tVO.isTradeFlatManuf;
				tStr[16] = tVO.isTradeFlatProvider;
				tStr[17] = StringUtils.formatEDouble(tVO.manufUnitprice, 4);
				tStr[18] = tVO.drawingPieceCode;
				tStr[19] = tVO.deliverGoodsAddr;
				tStr[20] = tVO.orderid;
				GSOrderBean  orderBean=orderDao.selectOrderByCode(tVO.orderid);
				tStr[21] = orderBean==null?"":orderBean.getGs_order_create_date().substring(0,10);
				tStr[22] = tVO.warehouseName;
				tStr[23] = tVO.CONTACT_PERSON;
				tStr[24] = tVO.CONTACT_tel;
				tRs.add(tStr);
			}
		}
		return tRs;
	}
	
	
	
	/**
	 * 通过订单编号得到订单明细详细信息
	 * 
	 * @param aOrderDetailIds
	 * @return
	 * @throws GSException
	 * @author wp
	 */
	public ArrayList getOrderDetailForSignNew(String aOrderDetailIds) throws GSException {
		ArrayList tRs = new ArrayList();
		GSOrderDetailDAO tOrderDetailDAO = new GSOrderDetailDAO();
		// 查询SQL
		StringBuffer tSql = new StringBuffer("select distinct a.GS_ORDER_DETAIL_ID as P1,a.GS_CONCENTRICITY_ID as P2,");
		tSql.append("b.NAME as P3,b.SPEC as P4,b.MODEL as P5,");
		tSql.append("b.product_BRAND as P6,c.NAME as P7,");
		tSql.append("a.GS_ORDER_COUNT as P8,b.product_unit as P9,a.GS_GOODS_UNITPRICE as P10,");
		tSql.append("a.GS_DELIVER_GOODS_DATE as P11,a.GS_DELIVER_GOODS_TIME as P12,a.GS_ORDER_DETAIL_STATUS as P13,");
		tSql.append("a.GS_ORDER_TEMPID as P14,b.IS_TRADEFLAT_product as P15,c.code as P16,");
		tSql.append("c.IS_TRADEFLAT_PROVIDER as P17,b.UNIT_PRICE as P18,b.quality_assure_period as P19, b.DRAWING_PIECE_CODE As P20, ");
		tSql.append("d.GS_DELIVER_GOODS_ADDR P21, a.Gs_Signin_Count P22, e.name P23,e.CONTACT_PERSON P24,e.CONTACK_TEL P25 ");
		tSql.append("from GS_ORDER_DETAIL a,t_product b,t_PROVIDER c,GS_ORDER d,t_warehouse e ");
		tSql.append("where ");
		tSql.append("a.GS_CONCENTRICITY_ID=b.CONCENTRICITY_code  and c.code=a.GS_PROVIDER_ID and a.GS_ORDER_TEMPID = d.GS_ORDER_TEMPID ");
		tSql.append(" and a.GS_PROVIDER_ID = '90001' and a.gs_manufacture_id=b.apep_code ");
		tSql.append(" and (a.GS_ORDER_DETAIL_STATUS in ('3','10','11','12')) and d.GS_WORKCORP_ID=e.code ");

		tSql.append(" and a.GS_ORDER_TEMPID='"+aOrderDetailIds+"'");

	
		// 执行查询
		ArrayList tList = tOrderDetailDAO.queryOrderDetail(tSql.toString(), new GSOrderDetailOfBusForSWVO());
		if (tList.size() > 0) {
			// 封装查询结果
			for (int i = 0; i < tList.size(); i++) {
				String tStr[] = new String[24];
				GSOrderDetailOfBusForSWVO tVO = (GSOrderDetailOfBusForSWVO) tList.get(i);
				tStr[0] = tVO.orderDetailId;
				tStr[1] = tVO.conCentricityId;
				tStr[2] = tVO.manufactureName;
				tStr[3] = tVO.manufSpec;
				tStr[4] = tVO.manufType;
				tStr[5] = tVO.manufBrand;
				tStr[6] = tVO.providerName;
				tStr[7] = StringUtils.formatEDouble(tVO.orderCount, 2);
				tStr[8] = tVO.quantUnit;
				tStr[9] = StringUtils.formatEDouble(tVO.goodUnitprice, 4);
				tStr[10] = StringUtils.formatEDouble(tVO.goodUnitprice * tVO.orderCount, 4);
				tStr[11] = tVO.deliverGoodsDate;
				tStr[12] = tVO.deliverGoodsTime == null ? "" : GSBaseManager.getDeliverGoodsTime(tVO.deliverGoodsTime);
				tStr[13] = GSBaseManager.getOrderDetailStatusName(tVO.orderDetailStatus);
				tStr[14] = tVO.providerId;
				tStr[15] = tVO.isTradeFlatManuf;
				tStr[16] = tVO.isTradeFlatProvider;
				tStr[17] = StringUtils.formatEDouble(tVO.manufUnitprice, 4);
				tStr[18] = tVO.drawingPieceCode;
				tStr[19] = tVO.deliverGoodsAddr;			
				tStr[20] = tVO.orderid;
				tStr[21] = tVO.warehouseName;
				tStr[22] = tVO.CONTACT_PERSON;
				tStr[23] = tVO.CONTACT_tel;
				tRs.add(tStr);
			}
		}
		return tRs;
	}
	
	/**
	 * 通过订单编号ID得到订单明细详细信息
	 * 
	 * @param aOrderDetailIds
	 * @return
	 * @throws GSException
	 * @author wp
	 */
	public ArrayList getOrderDetailForSignByOrders(String[] aOrderDetailIds,String status) throws GSException {
		ArrayList tRs = new ArrayList();
		GSOrderDetailDAO tOrderDetailDAO = new GSOrderDetailDAO();
		// 查询SQL
		StringBuffer tSql = new StringBuffer("select distinct a.GS_ORDER_DETAIL_ID as P1,a.GS_CONCENTRICITY_ID as P2,");
		tSql.append("b.NAME as P3,b.SPEC as P4,b.MODEL as P5,");
		tSql.append("b.product_BRAND as P6,c.NAME as P7,");
		tSql.append("a.GS_ORDER_COUNT as P8,b.product_unit as P9,a.GS_GOODS_UNITPRICE as P10,");
		tSql.append("a.GS_DELIVER_GOODS_DATE as P11,a.GS_DELIVER_GOODS_TIME as P12,a.GS_ORDER_DETAIL_STATUS as P13,");
		tSql.append("a.GS_ORDER_TEMPID as P14,b.IS_TRADEFLAT_product as P15,c.code as P16,");
		tSql.append("c.IS_TRADEFLAT_PROVIDER as P17,b.UNIT_PRICE as P18,b.quality_assure_period as P19, b.DRAWING_PIECE_CODE As P20, ");
		tSql.append("d.GS_DELIVER_GOODS_ADDR P21, a.Gs_Signin_Count P22 ");
		tSql.append("from GS_ORDER_DETAIL a,t_product b,t_PROVIDER c,GS_ORDER d ");
		tSql.append("where ");
		tSql.append("a.GS_CONCENTRICITY_ID=b.CONCENTRICITY_code  and c.code=a.GS_PROVIDER_ID and a.GS_ORDER_TEMPID = d.GS_ORDER_TEMPID ");
		tSql.append(" and a.gs_manufacture_id=b.apep_code ");
		tSql.append(" and a.GS_ORDER_DETAIL_STATUS='"+status+"'");
		tSql.append(" and a.gs_provider_id = '90001' ");
		tSql.append(" and a.GS_ORDER_TEMPID in (");
		for (int i = 0; i < aOrderDetailIds.length; i++) {
			if (i != 0) {
				tSql.append(",");
			}
			tSql.append("'").append(aOrderDetailIds[i]).append("'");
			if (i == aOrderDetailIds.length - 1) {
				tSql.append(")");
			}
		}
		// 执行查询
		ArrayList tList = tOrderDetailDAO.queryOrderDetail(tSql.toString(), new GSOrderDetailOfBusForSWVO());
		if (tList.size() > 0) {
			// 封装查询结果
			for (int i = 0; i < tList.size(); i++) {
				String tStr[] = new String[21];
				GSOrderDetailOfBusForSWVO tVO = (GSOrderDetailOfBusForSWVO) tList.get(i);
				tStr[0] = tVO.orderDetailId;
				tStr[1] = tVO.conCentricityId;
				tStr[2] = tVO.manufactureName;
				tStr[3] = tVO.manufSpec;
				tStr[4] = tVO.manufType;
				tStr[5] = tVO.manufBrand;
				tStr[6] = tVO.providerName;
				tStr[7] = StringUtils.formatEDouble(tVO.orderCount, 2);
				tStr[8] = tVO.quantUnit;
				tStr[9] = StringUtils.formatEDouble(tVO.goodUnitprice, 4);
				tStr[10] = StringUtils.formatEDouble(tVO.goodUnitprice * tVO.orderCount, 4);
				tStr[11] = tVO.deliverGoodsDate;
				tStr[12] = tVO.deliverGoodsTime == null ? "" : GSBaseManager.getDeliverGoodsTime(tVO.deliverGoodsTime);
				tStr[13] = GSBaseManager.getOrderDetailStatusName(tVO.orderDetailStatus);
				tStr[14] = tVO.providerId;
				tStr[15] = tVO.isTradeFlatManuf;
				tStr[16] = tVO.isTradeFlatProvider;
				tStr[17] = StringUtils.formatEDouble(tVO.manufUnitprice, 4);
				tStr[18] = tVO.drawingPieceCode;
				tStr[19] = tVO.deliverGoodsAddr;
				tStr[20] = tVO.signInCount+"";
				tRs.add(tStr);
			}
		}
		return tRs;
	}
	


	/**
	 * 保存非网上订单收货签收信息
	 * 
	 * @param aOrderDetailBean
	 *            订单明细Bean
	 * @return
	 * @throws GSException
	 */
	public boolean saveSignInfoOfNonFlat(GSOrderDetailBean aOrderDetailBean) throws GSException {
		boolean tFlag = false;
		Connection tConn = null;
		GSOrderDetailDAO tOrderDtlDAO = new GSOrderDetailDAO();
		try {
			tConn = tOrderDtlDAO.getConnetion();
			aOrderDetailBean.setGs_order_detail_status(GSBaseConstants.ORDER_DELIVERY_CONFIRM);
			// 格式化签收日期
			String temp = aOrderDetailBean.getGs_signin_date();
			if (temp != null && !"".equals(temp)) {
				temp = temp.substring(0, 4) + "-" + temp.substring(5, 7) + "-" + temp.substring(8, 10);
			}
			aOrderDetailBean.setGs_signin_date(temp);
			// 取得系统当前日期
			String tCurDT = DateUtil.formateDateTime(DateUtil.getCurrentTime("DT", "AD"));
			aOrderDetailBean.setGs_lastmodify_date(tCurDT);
			aOrderDetailBean.setGs_lastmodify_contents("非网上订单收货确认信息录入");
			tFlag = tOrderDtlDAO.updateOrderDetailStatus(aOrderDetailBean, tConn, GSBaseConstants.ORDER_ORDER_CONFIRM);
		} catch (GSException ge) {
			throw ge;
		} catch (Exception e) {
			GSLogWriter.error(this, e.toString());
			throw new GSException(GSException.E10065, GSException.E10065_MSG);
		} finally {
			GSOrderDetailDAO.close(tConn);
		}

		return tFlag;
	}

	/**
	 * 保存非网上订单收货签收信息
	 * 
	 * @param aOrderDetailBean
	 *            订单明细Bean
	 * @return
	 * @throws GSException
	 */
	public boolean saveSignInfoOfNonFlatsd(GSOrderDetailBean aOrderDetailBean) throws GSException {
		boolean tFlag = false;
		Connection tConn = null;
		GSOrderDetailDAO tOrderDtlDAO = new GSOrderDetailDAO();
		try {
			tConn = tOrderDtlDAO.getConnetion();
			aOrderDetailBean.setGs_order_detail_status(GSBaseConstants.ORDER_DELIVERY_CONFIRM);
			// 格式化签收日期
			String temp = aOrderDetailBean.getGs_signin_date();
			if (temp != null && !"".equals(temp)) {
				temp = temp.substring(0, 4) + "-" + temp.substring(5, 7) + "-" + temp.substring(8, 10);
			}
			aOrderDetailBean.setGs_signin_date(temp);
			// 取得系统当前日期
			String tCurDT = DateUtil.formateDateTime(DateUtil.getCurrentTime("DT", "AD"));
			aOrderDetailBean.setGs_lastmodify_date(tCurDT);
			aOrderDetailBean.setGs_lastmodify_contents("手工处理订单收货确认信息录入");
			tFlag = tOrderDtlDAO.updateOrderDetailStatus(aOrderDetailBean, tConn, GSBaseConstants.ORDER_ORDER_CONFIRM);
		} catch (GSException ge) {
			throw ge;
		} catch (Exception e) {
			GSLogWriter.error(this, e.toString());
			throw new GSException(GSException.E10065, GSException.E10065_MSG);
		} finally {
			GSOrderDetailDAO.close(tConn);
		}

		return tFlag;
	}

	/**
	 * 修改与未最终结算订单明细信息
	 * 
	 * @param aOrderDetailBean
	 * @param aBalYm
	 * @param aDeptId
	 * @return
	 * @throws GSException
	 */
	public boolean saveUnBalanceModSignInfoOfNonFlat(GSOrderDetailBean aOrderDetailBean, String aBalYm, String aDeptId, String state) throws GSException {
		boolean tFlag = false;
		Connection tConn = null;
		GSOrderDetailDAO tOrderDtlDAO = new GSOrderDetailDAO();
		GSManufactureDAO tMDAO = new GSManufactureDAO();
		try {
			tConn = tOrderDtlDAO.getConnetion();
			tConn.setAutoCommit(false);
			// 取得系统当前日期
			String tCurDT = DateUtil.formateDateTime(DateUtil.getCurrentTime("DT", "AD"));
			aOrderDetailBean.setGs_lastmodify_date(tCurDT);
			aOrderDetailBean.setGs_lastmodify_contents("调整与未结算数据相关的订单明细签收信息");

			// 查询该笔订单明细原签收数量和价格，算出总价
			GSOrderDetailBean tOrdDtlBean = tOrderDtlDAO.queryOrderDetailByDetailId(tConn, aOrderDetailBean.getGs_order_detail_id());
			// 格式化签收日期
			String temp = aOrderDetailBean.getGs_signin_date();
			if (temp == null || temp.trim().length() < 10) {
				temp = tOrdDtlBean.getGs_signin_date();
			} else {
				temp = temp.substring(0, 4) + "-" + temp.substring(5, 7) + "-" + temp.substring(8, 10);
			}
			aOrderDetailBean.setGs_signin_date(temp);
			double orgDetailAmt = tOrdDtlBean.getGs_signin_count() * tOrdDtlBean.getGs_goods_unitprice();
			double curDeatilAmt = aOrderDetailBean.getGs_signin_count() * aOrderDetailBean.getGs_goods_unitprice();
			GSBalanceMsgDAO tBalMsgDAO = new GSBalanceMsgDAO();
			// 状态不变
			aOrderDetailBean.setGs_order_detail_status(GSBaseConstants.ORDER_DELIVERY_CONFIRM);
			aOrderDetailBean.setGs_is_balanced(GSBaseConstants.BALANCE_STATUS);
			tFlag = tOrderDtlDAO.updateUnBalanceDetail(aOrderDetailBean, tConn, GSBaseConstants.ORDER_DELIVERY_CONFIRM);
			if (tFlag) {
				String cczxId = GSSystemConfigurator.getParam("gs.provider.cczxid");
				String is_tradeflat = tMDAO.getManufacture(tOrdDtlBean.getGs_manufacture_id()).getGs_is_tradeflat_manufacture();
				ArrayList tProvBalList = tBalMsgDAO.queryBalanceInfo("0".equals(is_tradeflat) ? cczxId : tOrdDtlBean.getGs_provider_id(), tOrdDtlBean
						.getGs_balance_month_provider());
				if (tFlag) {
					if (tProvBalList.size() == 1) {
						// 修改相关供应商结算信息的结算金额
						GSBalanceMsgBean tBalMsgBean = (GSBalanceMsgBean) tProvBalList.get(0);
						double totAmt = tBalMsgBean.getGs_balance_sum() - orgDetailAmt + curDeatilAmt;
						tBalMsgBean.setGs_balance_sum(totAmt);
						tBalMsgBean.setGs_operate_date(tCurDT);
						tBalMsgBean.setGs_operator_id(aOrderDetailBean.getGs_lastmodifer_id());
						tBalMsgBean.setGs_balance_sign(GSBaseConstants.UNBALANCE_STATUS);
						tFlag = tBalMsgDAO.updateBalanceSum(tConn, tBalMsgBean);
					} else {
						GSLogWriter.error(this, GSException.E40012_MSG);
						tConn.rollback();
						throw new GSException(GSException.E40012, GSException.E40012_MSG);
					}
					if (tFlag) {
						if ("2".equals(state)) {
							tConn.commit();
							GSLogWriter.info("非网上产品，不用提交到apep");
						} else {
							// 提交到交易平台
							String tRs = submitModifiedSignInfoToApep(aOrderDetailBean);
							if (tRs.equals("1")) {
								tConn.commit();
								GSLogWriter.info("修改保存并提交到交易平台成功");
							} else {
								GSLogWriter.error(this, "提交到交易平台返回失败");
								throw new GSException("提交到交易平台返回失败");
							}
						}
					} else {
						GSLogWriter.error(this, GSException.E40014_MSG);
						throw new GSException(GSException.E40014, GSException.E40014_MSG);
					}
				} else {
					GSLogWriter.error(this, GSException.E40013_MSG);
					throw new GSException(GSException.E40013, GSException.E40013_MSG);
				}
			} else {
				GSLogWriter.error(this, GSException.E40011_MSG);
				throw new GSException(GSException.E40011, GSException.E40011_MSG);
			}
		} catch (GSException ge) {
			try {
				tConn.rollback();
			} catch (SQLException se) {
				se.printStackTrace();
			}
			throw ge;
		} catch (Exception e) {
			try {
				tConn.rollback();
			} catch (SQLException se) {
				se.printStackTrace();
			}

			GSLogWriter.error(this, e.toString());
			throw new GSException(GSException.E10065, GSException.E10065_MSG);
		} finally {
			try {
				if (tConn != null) {
					tConn.setAutoCommit(true);
					tConn.close();
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return tFlag;
	}

	/**
	 * 向交易平台发送订单签收信息修改内容
	 * 
	 * @param aOrderDetailBean
	 * @return
	 * @throws GSException
	 */
	private String submitModifiedSignInfoToApep(GSOrderDetailBean aOrderDetailBean) throws GSException, Exception {
		int i = 0;
		String tRs = "";
		GSOrderDetailDAO odDao = new GSOrderDetailDAO();
		String purName = odDao.getWorkCorp(aOrderDetailBean.getGs_order_detail_id());

		/*
		 * StringBuffer tSb = new StringBuffer("Action=AmendOrder&Count=" + 1);
		 * tSb.append("&CusOrderItemCode_" +i +"=" +
		 * aOrderDetailBean.getGs_order_detail_id()); tSb.append("&SendCode_" +
		 * i +"=" + aOrderDetailBean.getGs_deliver_goods_id());
		 * tSb.append("&SurePrice_" + i + "=" +
		 * aOrderDetailBean.getGs_goods_unitprice()); tSb.append("&ReceiveDate_" +
		 * i +"=" + aOrderDetailBean.getGs_signin_date());
		 * tSb.append("&ReceiveQty_" +i+"=" +
		 * aOrderDetailBean.getGs_signin_count()); tSb.append("&ReceivePerson_" +
		 * i + "=" + aOrderDetailBean.getGs_signin_person());
		 * tSb.append("&SendPerson_" + i + "=" +
		 * aOrderDetailBean.getGs_deliveryman()); tSb.append("&SendTel_" + i +
		 * "=" + aOrderDetailBean.getGs_deliver_goods_phone());
		 * tSb.append("&CusCode_" + i +"=" +
		 * GSSystemConfigurator.getParam("gs.purcode")); tSb.append("&PurName_" +
		 * i + "=" + purName);// 订货单位编号 tSb.append("&");
		 */
		ParameterFactory pf = new ParameterFactory();
		pf.addParam("Action", "AmendOrder");
		pf.addParam("Count", "1");
		pf.addParam("CusOrderItemCode_" + i, aOrderDetailBean.getGs_order_detail_id());
		pf.addParam("SendCode_" + i, aOrderDetailBean.getGs_deliver_goods_id());
		pf.addParam("SurePrice_" + i, String.valueOf(aOrderDetailBean.getGs_goods_unitprice()));
		pf.addParam("ReceiveDate_" + i, aOrderDetailBean.getGs_signin_date());
		pf.addParam("ReceiveQty_" + i, String.valueOf(aOrderDetailBean.getGs_signin_count()));
		pf.addParam("ReceivePerson_" + i, aOrderDetailBean.getGs_signin_person());
		pf.addParam("SendPerson_" + i, aOrderDetailBean.getGs_deliveryman());
		pf.addParam("SendTel_" + i, aOrderDetailBean.getGs_deliver_goods_phone());
		pf.addParam("CusCode_" + i, GSSystemConfigurator.getParam("gs.purcode"));
		pf.addParam("PurName_" + i, purName);

		GSLogWriter.debug(this, "传送内容" + pf.getStrStream());
		// 取得配置文件中服务端IP和端口参数
		String tIP = GSSystemConfigurator.getParam("gs.ip");
		String tPort = GSSystemConfigurator.getParam("gs.port");
		// 连接服务端
		GSClientSocket tClientSocket = new GSClientSocket(tIP, Integer.parseInt(tPort));

		// 发送订单信息到采购网
		tRs = tClientSocket.sendContents(pf.getStrStream());
		return tRs;
	}

	/**
	 * 按条件取得运营公司应急采购信息
	 * 
	 * @param aGSOrderVO
	 *            封装订单查询参数的VO对象
	 * @return
	 * @throws GSException
	 */
	public ArrayList getEmergencyOrderAndDetail(GSOrderEmergencyVO aGSOrderEmergencyVO, ArrayList tOrg) throws GSException {
		ArrayList tOrderList = new ArrayList();
		GSOrderDAO tGSOrderDAO = new GSOrderDAO();
		ArrayList tList = new ArrayList();
		Connection tConn = null;
		try {
			// 取得DB连接
			tConn = tGSOrderDAO.getConnetion();
			String[] tDateStr = new String[2];
			// 取得查询参数订单创建最小日期和最大日期
			tDateStr[0] = aGSOrderEmergencyVO.firstdate;
			tDateStr[1] = aGSOrderEmergencyVO.lastdate;
			// 格式化日期
			tDateStr = DateUtil.formateDate(tDateStr);
			aGSOrderEmergencyVO.firstdate = tDateStr[0];
			aGSOrderEmergencyVO.lastdate = tDateStr[1];
			// 查询所有订单及明细
			tOrderList = tGSOrderDAO.queryEmergencyOrder(tConn, aGSOrderEmergencyVO, tOrg);
			if (tOrderList.size() > 0) {

				for (int i = 0; i < tOrderList.size(); i++) {

					GSOrderEmergencyOfWorkingVO tGSOrderEmergencyOfWorkingVO = (GSOrderEmergencyOfWorkingVO) tOrderList.get(i);
					// 判断新取得的OrderSubmitVO对象中的订单编号是否与前一对象中订单编号相同
					// if(tOrderId.equals(tGSOrderSubmitVO.orderid)){
					// 订单编号相同则将取得的产品信息放入同一订单VO对象的ArrayList对象中
					// if(tConCentricityId.equals(tGSOrderSubmitVO.concentricityId)){
					// continue;
					// }
					String[] tStr = new String[22];
					tStr[0] = tGSOrderEmergencyOfWorkingVO.goodsid;
					tStr[1] = GSBaseManager.getOrderCategoryTag(tGSOrderEmergencyOfWorkingVO.category);
					tStr[2] = GSBaseManager.getOrderDetailStatus(tGSOrderEmergencyOfWorkingVO.orderdetailstatus);
					tStr[3] = tGSOrderEmergencyOfWorkingVO.orgname;
					tStr[4] = tGSOrderEmergencyOfWorkingVO.concentricityid;
					tStr[5] = tGSOrderEmergencyOfWorkingVO.manufacturename;
					tStr[6] = tGSOrderEmergencyOfWorkingVO.manufacturespec;
					tStr[7] = tGSOrderEmergencyOfWorkingVO.manufacturetype;
					tStr[8] = tGSOrderEmergencyOfWorkingVO.manufacturebrand;
					tStr[9] = tGSOrderEmergencyOfWorkingVO.provider;
					tStr[10] = StringUtils.formatEDouble(tGSOrderEmergencyOfWorkingVO.ordercount, 2);
					tStr[11] = StringUtils.formatEDouble(tGSOrderEmergencyOfWorkingVO.signincount, 2);
					tStr[12] = StringUtils.formatEDouble(tGSOrderEmergencyOfWorkingVO.signinprice, 4);
					tStr[13] = tGSOrderEmergencyOfWorkingVO.signindate;
					tStr[14] = tGSOrderEmergencyOfWorkingVO.quantunit;
					tStr[15] = tGSOrderEmergencyOfWorkingVO.ordertempid;
					tStr[16] = tGSOrderEmergencyOfWorkingVO.orderdetailid;
					tStr[17] = tGSOrderEmergencyOfWorkingVO.category;
					tStr[18] = tGSOrderEmergencyOfWorkingVO.orderdetailstatus;
					tStr[19] = StringUtils.formatEDouble(tGSOrderEmergencyOfWorkingVO.signincount * tGSOrderEmergencyOfWorkingVO.signinprice, 4);
					tStr[20] = tGSOrderEmergencyOfWorkingVO.mode;
					tStr[21] = DefineDic.getBalanceMode(tGSOrderEmergencyOfWorkingVO.mode);
					tList.add(tStr);

				}
			}
		} catch (GSException ge) {
			throw ge;
		} catch (Exception e) {
			GSLogWriter.debug(this, e.toString());
			throw new GSException(GSException.E10041, GSException.E10041_MSG);
		} finally {
			GSOrderDAO.close(tConn);
		}
		return tList;
	}

	/**
	 * 删除应急采购记录
	 * 
	 * @param
	 * 
	 * throws GSException
	 */
	public static void withdrawEmergencyTask(String aTempId, String aDetailId) throws GSException {
		GSOrderDAO tGSOrderDAO = new GSOrderDAO();
		// 删除应急采购记录
		if (tGSOrderDAO.delete(aTempId, aDetailId) == false) {
			throw new GSException("");
		}
	}

	/**
	 * 应急采购信息选择订单编码查询订单明细信息
	 * 
	 * @param aOrderId
	 *            订单编码
	 * @return
	 * @throws GSException
	 */
	public ArrayList getEmergencyOrderDetailByOrderId(String aOrderId) throws GSException {
		ArrayList tList = new ArrayList();
		try {
			GSOrderDetailDAO tGSOrderDetailDAO = new GSOrderDetailDAO();

			// 查询订单明细
			ArrayList tRs = tGSOrderDetailDAO.EmergencyOrderQueryDetail(aOrderId);
			if (tRs.size() > 0) {
				for (int i = 0; i < tRs.size(); i++) {
					String[] tStr = new String[15];
					GSEmergencyOrderDetailVO tGSEmergencyOrderDetailVO = (GSEmergencyOrderDetailVO) tRs.get(i);
					// 取出订单包含的产品信息VO对象组成String数组
					tStr[0] = tGSEmergencyOrderDetailVO.concentricityid;
					tStr[1] = tGSEmergencyOrderDetailVO.manufactureid;
					tStr[2] = tGSEmergencyOrderDetailVO.manufacturename;
					tStr[3] = tGSEmergencyOrderDetailVO.manufacturespec;
					tStr[4] = tGSEmergencyOrderDetailVO.manfacturetype;
					tStr[5] = tGSEmergencyOrderDetailVO.manufacturebrand;
					tStr[6] = StringUtils.formatEDouble(tGSEmergencyOrderDetailVO.ordercount, 2);
					tStr[7] = StringUtils.formatEDouble(tGSEmergencyOrderDetailVO.singnincount, 2);
					tStr[8] = tGSEmergencyOrderDetailVO.quantunit;
					tStr[9] = StringUtils.formatEDouble(tGSEmergencyOrderDetailVO.goodsunitprice, 4);
					tStr[10] = StringUtils.formatEDouble(tGSEmergencyOrderDetailVO.signinprice, 4);
					tStr[11] = GSBaseManager.getProviderShortName(tGSEmergencyOrderDetailVO.providerid);
					tStr[12] = tGSEmergencyOrderDetailVO.orderId;
					tStr[13] = tGSEmergencyOrderDetailVO.orderDetailId;
					tStr[14] = StringUtils.formatEDouble(tGSEmergencyOrderDetailVO.signinprice * tGSEmergencyOrderDetailVO.singnincount, 4);

					tList.add(tStr);
				}
			}
		} catch (GSException ge) {
			throw ge;
		} catch (Exception e) {
			GSLogWriter.error(this, e.toString());
			throw new GSException(GSException.E10042, GSException.E10042_MSG);
		}
		return tList;
	}

	/**
	 * 取得已纳入结算的订单明细
	 * 
	 * @param aVO
	 * @param aOrgList
	 * @param pageNo
	 * @param pageSize
	 * @return
	 * @throws GSException
	 */
	public ArrayList getSignedDetail(GSUnBalanceDetailQryVO aVO, ArrayList aOrgList, int pageNo, int pageSize) throws GSException {
		ArrayList tList = new ArrayList();
		GSOrderDetailDAO tOrderDtlDAO = new GSOrderDetailDAO();

		try {
			GSBalanceMsgDAO tBalMsgDAO = new GSBalanceMsgDAO();
			ArrayList tBalList = tBalMsgDAO.queryBalanceInfo(aVO.deptId, aVO.balanceYM);
			if (tBalList.size() == 1) {
				GSBalanceMsgBean tBean = (GSBalanceMsgBean) tBalList.get(0);
				aVO.endBalDate = DateUtil.splitSpecChar(tBean.getGs_end_date());
				ArrayList tRs = tOrderDtlDAO.querySignedDetail(aVO, aOrgList, pageNo, pageSize);
				if (tRs.size() > 0) {
					for (int i = 0; i < tRs.size(); i++) {
						GSUnBalanceDetailQryResultVO tVO = (GSUnBalanceDetailQryResultVO) tRs.get(i);
						String[] tStr = new String[21];
						tStr[0] = tVO.orderId;
						tStr[1] = tVO.orderDetailId;
						tStr[2] = tVO.deliverGoodId;
						tStr[3] = tVO.deptName;
						tStr[4] = aVO.deptId;
						tStr[5] = tVO.providerName;
						tStr[6] = tVO.concentricity;
						tStr[7] = tVO.manufName;
						tStr[8] = tVO.isTradeFlatManuf;
						tStr[9] = tVO.isTradeFlatProvider;
						tStr[10] = tVO.spec;
						tStr[11] = tVO.type;
						tStr[12] = tVO.brand;
						tStr[13] = tVO.manufacter;
						tStr[14] = StringUtils.formatEDouble(tVO.orderCount, 2);
						tStr[15] = tVO.quantUnit;
						tStr[16] = StringUtils.formatEDouble(tVO.orgUnitPrice, 4);
						tStr[17] = StringUtils.formatEDouble(tVO.signCount, 2);
						tStr[18] = StringUtils.formatEDouble(tVO.signUnitPrice, 4);
						tStr[19] = tVO.signDate;
						tStr[20] = tVO.mode;
						tList.add(tStr);
					}
				}
			} else {
				GSLogWriter.error(this, GSException.E40005_MSG);
			}
		} catch (GSException ge) {
			throw ge;
		} catch (Exception e) {
			GSLogWriter.error(this, e.toString());
			throw new GSException(e.toString());
		}
		return tList;
	}

	/**
	 * 根据已知的订单编号，明细编号取得已纳入结算的订单明细
	 * 
	 * @param aOrderId
	 *            订单编号
	 * @param OrderDetailId
	 *            订单明细编号
	 * @return
	 * @throws GSException
	 */
	public ArrayList getOrderDetailForBalanceSignInfo(String aOrderId, String aOrderDetailId) throws GSException {
		ArrayList tRs = new ArrayList();
		GSOrderDetailDAO tOrderDetailDAO = new GSOrderDetailDAO();
		// 查询SQL
		StringBuffer tSql = new StringBuffer("select distinct a.GS_ORDER_DETAIL_ID as P1,a.GS_CONCENTRICITY_ID as P2,");
		tSql.append("b.GS_MANUFACTURE_NAME as P3,b.GS_MANUFACTURE_SPEC as P4,b.GS_MANUFACTURE_TYPE as P5,");
		tSql.append("b.GS_MANUFACTURE_BRAND as P6,c.GS_PROVIDER_SHORTNAME as P7,");
		tSql.append("a.GS_ORDER_COUNT as P8,b.GS_QUANT_UNIT as P9,a.GS_GOODS_UNITPRICE as P10,");
		tSql.append("a.GS_DELIVER_GOODS_DATE as P11,a.GS_DELIVER_GOODS_TIME as P12,a.GS_ORDER_DETAIL_STATUS as P13,");
		tSql.append("a.GS_ORDER_TEMPID as P14,b.GS_IS_TRADEFLAT_MANUFACTURE as P15,c.GS_PROVIDER_ID as P16,");
		tSql.append("c.GS_IS_TRADEFLAT_PROVIDER as P17,a.GS_SIGNIN_PERSON as P18,a.GS_SIGNIN_COUNT as P19,");
		tSql.append("a.GS_SIGNIN_DATE as P20,a.GS_DELIVERYMAN as P21,a.GS_DELIVER_GOODS_PHONE as P22,");
		tSql.append("a.GS_DELIVER_GOODS_CONFIRM_DATE as P23,a.GS_DELIVER_GOODS_CONFIRM_TIME as P24,");
		tSql.append("a.GS_DELIVER_GOODS_ID as P25,a.GS_DELIVER_GOODS_COUNTS as P26,b.GS_MANUFACTURE_UNITPRICE as P27 ");
		tSql.append("from GS_ORDER_DETAIL a,GS_MANUFACTURE b,GS_PROVIDER c ");
		tSql.append("where a.GS_ORDER_TEMPID='" + aOrderId + "' and a.GS_ORDER_DETAIL_ID = '" + aOrderDetailId + "' ");
		tSql.append("and a.GS_CONCENTRICITY_ID=b.GS_CONCENTRICITY_ID  and c.GS_PROVIDER_ID=a.GS_PROVIDER_ID ");
		tSql.append("and a.gs_manufacture_id=b.gs_manufacture_id ");
		// 执行查询
		ArrayList tList = tOrderDetailDAO.queryOrderDetail(tSql.toString(), new GSBalanceDetailSignModifyVO());
		if (tList.size() > 0) {
			// 封装查询结果
			for (int i = 0; i < tList.size(); i++) {
				String tStr[] = new String[26];
				GSBalanceDetailSignModifyVO tVO = (GSBalanceDetailSignModifyVO) tList.get(i);
				tStr[0] = tVO.orderDetailId;
				tStr[1] = tVO.conCentricityId;
				tStr[2] = tVO.manufactureName;
				tStr[3] = tVO.manufSpec;
				tStr[4] = tVO.manufType;
				tStr[5] = tVO.manufBrand;
				tStr[6] = tVO.providerName;
				tStr[7] = StringUtils.formatEDouble(tVO.orderCount, 2);
				tStr[8] = tVO.quantUnit;
				tStr[9] = StringUtils.formatEDouble(tVO.goodUnitprice, 4); // 最终单价
				tStr[10] = StringUtils.formatEDouble(tVO.manufUnitprice * tVO.orderCount, 4);
				tStr[11] = tVO.deliverGoodsDate == null ? "" : tVO.deliverGoodsDate;
				tStr[12] = tVO.deliverGoodsTime == null ? "" : GSBaseManager.getDeliverGoodsTime(tVO.deliverGoodsTime);
				tStr[13] = GSBaseManager.getOrderDetailStatusName(tVO.orderDetailStatus);
				tStr[14] = tVO.providerId;
				tStr[15] = tVO.isTradeFlatManuf;
				tStr[16] = tVO.isTradeFlatProvider;
				tStr[17] = tVO.signPerson;
				tStr[18] = String.valueOf(tVO.signCount);
				tStr[19] = tVO.signDate;
				tStr[20] = tVO.deliveryman;
				tStr[21] = tVO.deliverGoodsPhone;
				tStr[22] = tVO.deliverGoodsConfirmDate + tVO.deliverGoodsConfirmTime;
				tStr[23] = tVO.deliverGoodsId;
				tStr[24] = String.valueOf(tVO.deliverGoodsCounts);
				tStr[25] = StringUtils.formatEDouble(tVO.manufUnitprice, 4); // 产品单价
				tRs.add(tStr);
			}
		}
		return tRs;
	}

	/**
	 * 取得结算表中已结算信息相关的订单明细
	 * 
	 * @param aDeptId
	 *            单位编号
	 * @param aDeptCategory
	 *            单位种类
	 * @param aBalYm
	 *            结算月份
	 * @param pageNo
	 *            页号
	 * @param pageSize
	 *            每页笔数
	 * @return
	 * @throws GSException
	 */
	public ArrayList getBalancedAssociatedOrderDetail(String aDeptId, String aDeptCategory, String aBalYm, int pageNo, int pageSize) throws GSException {
		ArrayList tList = new ArrayList();
		GSOrderDetailDAO tOrderDetailDAO = new GSOrderDetailDAO();
		try {
			GSBalanceMsgDAO tBalMsgDAO = new GSBalanceMsgDAO();
			ArrayList tBalList = tBalMsgDAO.queryBalanceInfo(aDeptId, aBalYm);
			if (tBalList.size() == 1) {
				GSBalanceMsgBean tBean = (GSBalanceMsgBean) tBalList.get(0);
				String tEndBalDate = DateUtil.splitSpecChar(tBean.getGs_end_date());
				// String tStrBalDate =
				// DateUtil.splitSpecChar(tBean.getGs_start_date());
				ArrayList tRs = tOrderDetailDAO.queryDetailAssociatedBalanced(aDeptId, aDeptCategory, tEndBalDate, aBalYm, pageNo, pageSize);
				for (int i = 0; i < tRs.size(); i++) {
					GSBalancedDetailQryResultVO tVO = (GSBalancedDetailQryResultVO) tRs.get(i);
					String[] tStr = new String[20];
					tStr[0] = tVO.orderId;
					tStr[1] = tVO.orderDetailId;
					tStr[2] = tVO.deliverGoodId;
					tStr[3] = tVO.deptName;
					tStr[4] = tVO.providerId;
					tStr[5] = tVO.providerName;
					tStr[6] = tVO.concentricity;
					tStr[7] = tVO.manufName;
					tStr[8] = tVO.isTradeFlatManuf;
					tStr[9] = tVO.isTradeFlatProvider;
					tStr[10] = tVO.spec;
					tStr[11] = tVO.type;
					tStr[12] = tVO.brand;
					tStr[13] = tVO.manufacter;
					tStr[14] = StringUtils.formatEDouble(tVO.orderCount, 2);
					tStr[15] = tVO.quantUnit;
					tStr[16] = StringUtils.formatEDouble(tVO.orgUnitPrice, 2);
					tStr[17] = StringUtils.formatEDouble(tVO.signCount, 2);
					tStr[18] = StringUtils.formatEDouble(tVO.signUnitPrice, 2);
					tStr[19] = tVO.signDate == null ? "" : tVO.signDate;
					tList.add(tStr);
				}
			} else {
				GSLogWriter.error(this, GSException.E40005_MSG);
				throw new GSException(GSException.E40005, GSException.E40005_MSG);
			}
		} catch (GSException ge) {
			throw ge;
		} catch (Exception e) {
			GSLogWriter.error(this, e.toString());
			throw new GSException(e.toString());
		}
		return tList;
	}

	/**
	 * 导出结算明细的excel文档格式
	 * 
	 * @param aForm
	 *            页面参数
	 * @return
	 * @throws GSException
	 */
	public boolean exportBalancedDetail(GSBalanceDetlOptForm aForm) throws GSException {
		boolean tFlag = false;
		GSOrderDetailDAO tOrderDetailDAO = new GSOrderDetailDAO();
		try {
			GSBalanceMsgDAO tBalMsgDAO = new GSBalanceMsgDAO();
			ArrayList tBalList = tBalMsgDAO.queryBalanceInfo(aForm.getDeptId(), aForm.getBalanceYM());
			if (tBalList.size() == 1) {
				GSBalanceMsgBean tBean = (GSBalanceMsgBean) tBalList.get(0);
				String tEndBalDate = DateUtil.splitSpecChar(tBean.getGs_end_date());
				// 查询明细
				ArrayList tRs = tOrderDetailDAO.queryDetailAssociatedBalanced(aForm.getDeptId(), aForm.getDeptCategory(), tEndBalDate, aForm.getBalanceYM());

				// 写文件
				writeFile(aForm.getDeptCategory(), aForm.getDeptId(), aForm.getBalanceYM(), tRs, aForm);
				tFlag = true;
			} else {
				GSLogWriter.error(this, GSException.E40005_MSG);
				throw new GSException(GSException.E40005, GSException.E40005_MSG);
			}
		} catch (GSException ge) {
			throw ge;
		} catch (Exception e) {
			GSLogWriter.error(this, e.toString());
			throw new GSException(e.toString());
		}
		return tFlag;
	}

	/**
	 * 写Excel文件
	 * 
	 * @param aDeptName
	 * @param aBalYM
	 * @param aList
	 * @param aForm
	 * @return
	 * @throws GSException
	 */
	private boolean writeFile(String aDeptCategory, String aDeptId, String aBalYM, ArrayList aList, GSBaseForm aForm) throws GSException {
		boolean result = true;
		try {
			HSSFWorkbook tWBook = new HSSFWorkbook();
			HSSFCellStyle tStyle = tWBook.createCellStyle();
			HSSFFont tFont = tWBook.createFont();

			HSSFSheet tSheet = tWBook.createSheet("1");
			HSSFRow tRow = tSheet.createRow(0);
			HSSFCell tCell = tRow.createCell((short) 0);
			tCell.setEncoding(HSSFCell.ENCODING_UTF_16);
			tCell.setCellType(HSSFCell.CELL_TYPE_STRING);
			// 写第一行标题
			tFont.setFontHeightInPoints((short) 12);
			tFont.setColor(HSSFColor.GREEN.index);
			tStyle.setFont(tFont);
			tCell.setCellStyle(tStyle);
			String tName = "";
			GSOrganizationDAO tOrgDAO = new GSOrganizationDAO();
			GSProviderDAO pDAO = new GSProviderDAO();
			String cczx = pDAO.queryProvider(GSSystemConfigurator.getParam("gs.provider.cczxid")).getGs_provider_shortname();
			if (aDeptCategory.equals(GSBaseConstants.BALANCE_ORDERDEPT_TYPE)) {

				// 查询订货单位名称
				tName = tOrgDAO.queryOrgName(aDeptId);
			} else {
				GSProviderDAO tProvDAO = new GSProviderDAO();
				tName = tProvDAO.queryProvider(aDeptId).getGs_provider_shortname();
			}
			String tDate = aBalYM.substring(0, 4) + "年" + aBalYM.substring(4) + "月";
			tCell.setCellValue(tName + tDate + "对帐信息");

			// 写明细title
			tRow = tSheet.createRow(2);
			tCell = tRow.createCell((short) 0);
			tCell.setEncoding(HSSFCell.ENCODING_UTF_16);
			tCell.setCellValue("送货单号");
			tFont = tWBook.createFont();
			tFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
			tStyle = tWBook.createCellStyle();
			tStyle.setFont(tFont);
			tCell.setCellStyle(tStyle);

			tCell = tRow.createCell((short) 1);
			tCell.setEncoding(HSSFCell.ENCODING_UTF_16);
			if (aDeptCategory.equals(GSBaseConstants.BALANCE_ORDERDEPT_TYPE)) {
				tCell.setCellValue("供应商");
			} else {
				tCell.setCellValue("订货单位");
			}
			tFont = tWBook.createFont();
			tFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
			tStyle = tWBook.createCellStyle();
			tStyle.setFont(tFont);
			tCell.setCellStyle(tStyle);

			tCell = tRow.createCell((short) 2);
			tCell.setEncoding(HSSFCell.ENCODING_UTF_16);
			tCell.setCellValue("集中编码");
			tFont = tWBook.createFont();
			tFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
			tStyle = tWBook.createCellStyle();
			tStyle.setFont(tFont);
			tCell.setCellStyle(tStyle);

			tCell = tRow.createCell((short) 3);
			tCell.setEncoding(HSSFCell.ENCODING_UTF_16);
			tCell.setCellValue("产品名称");
			tFont = tWBook.createFont();
			tFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
			tStyle = tWBook.createCellStyle();
			tStyle.setFont(tFont);
			tCell.setCellStyle(tStyle);

			tCell = tRow.createCell((short) 4);
			tCell.setEncoding(HSSFCell.ENCODING_UTF_16);
			tCell.setCellValue("规格");
			tFont = tWBook.createFont();
			tFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
			tStyle = tWBook.createCellStyle();
			tStyle.setFont(tFont);
			tCell.setCellStyle(tStyle);

			tCell = tRow.createCell((short) 5);
			tCell.setEncoding(HSSFCell.ENCODING_UTF_16);
			tCell.setCellValue("型号");
			tFont = tWBook.createFont();
			tFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
			tStyle = tWBook.createCellStyle();
			tStyle.setFont(tFont);
			tCell.setCellStyle(tStyle);

			tCell = tRow.createCell((short) 6);
			tCell.setEncoding(HSSFCell.ENCODING_UTF_16);
			tCell.setCellValue("品牌");
			tFont = tWBook.createFont();
			tFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
			tStyle = tWBook.createCellStyle();
			tStyle.setFont(tFont);
			tCell.setCellStyle(tStyle);

			tCell = tRow.createCell((short) 7);
			tCell.setEncoding(HSSFCell.ENCODING_UTF_16);
			tCell.setCellValue("生产厂商");
			tFont = tWBook.createFont();
			tFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
			tStyle = tWBook.createCellStyle();
			tStyle.setFont(tFont);
			tCell.setCellStyle(tStyle);

			tCell = tRow.createCell((short) 8);
			tCell.setEncoding(HSSFCell.ENCODING_UTF_16);
			tCell.setCellValue("签收数量");
			tFont = tWBook.createFont();
			tFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
			tStyle = tWBook.createCellStyle();
			tStyle.setFont(tFont);
			tCell.setCellStyle(tStyle);

			tCell = tRow.createCell((short) 9);
			tCell.setEncoding(HSSFCell.ENCODING_UTF_16);
			tCell.setCellValue("单位");
			tFont = tWBook.createFont();
			tFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
			tStyle = tWBook.createCellStyle();
			tStyle.setFont(tFont);
			tCell.setCellStyle(tStyle);

			tCell = tRow.createCell((short) 10);
			tCell.setEncoding(HSSFCell.ENCODING_UTF_16);
			tCell.setCellValue("签收价格");
			tFont = tWBook.createFont();
			tFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
			tStyle = tWBook.createCellStyle();
			tStyle.setFont(tFont);
			tCell.setCellStyle(tStyle);

			tCell = tRow.createCell((short) 11);
			tCell.setEncoding(HSSFCell.ENCODING_UTF_16);
			tCell.setCellValue("签收总价");
			tFont = tWBook.createFont();
			tFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
			tStyle = tWBook.createCellStyle();
			tStyle.setFont(tFont);
			tCell.setCellStyle(tStyle);

			tCell = tRow.createCell((short) 12);
			tFont = tWBook.createFont();
			tFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
			tStyle = tWBook.createCellStyle();
			tStyle.setFont(tFont);
			tCell.setCellStyle(tStyle);
			tCell.setEncoding(HSSFCell.ENCODING_UTF_16);
			tCell.setCellValue("签收日期");

			tCell = tRow.createCell((short) 13);
			tCell.setEncoding(HSSFCell.ENCODING_UTF_16);
			tCell.setCellValue("小计");
			tFont = tWBook.createFont();
			tFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
			tStyle = tWBook.createCellStyle();
			tStyle.setFont(tFont);
			tCell.setCellStyle(tStyle);

			String tDeptId = "";
			double tPerSum = 0;
			double tSum = 0;
			double totalSum = 0;

			GSManufactureDAO mDAO = new GSManufactureDAO();
			// 写明细内容
			for (int i = 0; i < aList.size(); i++) {
				GSBalancedDetailQryResultVO tVO = (GSBalancedDetailQryResultVO) aList.get(i);
				tDeptId = tVO.providerId;
				tRow = tSheet.createRow((short) (3 + i));
				tCell = tRow.createCell((short) 0);
				tCell.setEncoding(HSSFCell.ENCODING_UTF_16);
				tCell.setCellValue(tVO.deliverGoodId);

				tCell = tRow.createCell((short) 1);
				tCell.setEncoding(HSSFCell.ENCODING_UTF_16);
				if (aDeptCategory.equals(GSBaseConstants.BALANCE_ORDERDEPT_TYPE)) {
					if ("0".equals(mDAO.getManufacture(tVO.manufactureId).getGs_is_tradeflat_manufacture())) {
						tCell.setCellValue(cczx);
					} else {
						tCell.setCellValue(tVO.providerName);
					}
				} else {
					tCell.setCellValue(tVO.deptName);
				}

				tCell = tRow.createCell((short) 2);
				tCell.setEncoding(HSSFCell.ENCODING_UTF_16);
				tCell.setCellValue(tVO.concentricity);

				tCell = tRow.createCell((short) 3);
				tCell.setEncoding(HSSFCell.ENCODING_UTF_16);
				tCell.setCellValue(tVO.manufName);

				tCell = tRow.createCell((short) 4);
				tCell.setEncoding(HSSFCell.ENCODING_UTF_16);
				tCell.setCellValue(tVO.spec);

				tCell = tRow.createCell((short) 5);
				tCell.setEncoding(HSSFCell.ENCODING_UTF_16);
				tCell.setCellValue(tVO.type);

				tCell = tRow.createCell((short) 6);
				tCell.setEncoding(HSSFCell.ENCODING_UTF_16);
				tCell.setCellValue(tVO.brand);

				tCell = tRow.createCell((short) 7);
				tCell.setEncoding(HSSFCell.ENCODING_UTF_16);
				tCell.setCellValue(tVO.manufacter);

				tCell = tRow.createCell((short) 8);
				tCell.setCellValue(tVO.signCount);
				tStyle = tWBook.createCellStyle();
				tStyle.setDataFormat(tWBook.createDataFormat().getFormat("0.00"));
				tCell.setCellStyle(tStyle);

				tCell = tRow.createCell((short) 9);
				tCell.setEncoding(HSSFCell.ENCODING_UTF_16);
				tCell.setCellValue(tVO.quantUnit);

				tCell = tRow.createCell((short) 10);
				tCell.setCellValue(tVO.signUnitPrice);
				tStyle = tWBook.createCellStyle();
				tStyle.setDataFormat(tWBook.createDataFormat().getFormat("0.0000"));
				tCell.setCellStyle(tStyle);

				tPerSum = tVO.signUnitPrice * tVO.signCount;
				tCell = tRow.createCell((short) 11);
				tCell.setCellValue(tPerSum);
				tStyle = tWBook.createCellStyle();
				tStyle.setDataFormat(tWBook.createDataFormat().getFormat("0.0000"));
				tCell.setCellStyle(tStyle);

				tCell = tRow.createCell((short) 12);
				tCell.setEncoding(HSSFCell.ENCODING_UTF_16);
				tCell.setCellValue(tVO.signDate);

				// 按供应商或订货单位统计金额
				tCell = tRow.createCell((short) 13);
				if (i < aList.size() - 1) {
					GSBalancedDetailQryResultVO tVO2 = (GSBalancedDetailQryResultVO) aList.get(i + 1);
					if (!tDeptId.equals(tVO2.providerId)) {
						tSum = tPerSum + tSum;
						tCell.setCellValue(tSum);
						tStyle = tWBook.createCellStyle();
						tStyle.setDataFormat(tWBook.createDataFormat().getFormat("0.0000"));
						tCell.setCellStyle(tStyle);
						tSum = 0;
					} else {
						tCell.setCellValue("");
						tSum = tPerSum + tSum;
					}
				} else if (i == aList.size() - 1) {
					tSum = tPerSum + tSum;
					tCell.setCellValue(tSum);
					tStyle = tWBook.createCellStyle();
					tStyle.setDataFormat(tWBook.createDataFormat().getFormat("0.0000"));
					tCell.setCellStyle(tStyle);
				}

				totalSum = totalSum + tPerSum;
			}
			// 显示总金额
			tRow = tSheet.createRow(aList.size() + 3);
			tCell = tRow.createCell((short) 12);
			tCell.setEncoding(HSSFCell.ENCODING_UTF_16);
			tCell.setCellValue("总计：");
			tCell = tRow.createCell((short) 13);
			tCell.setCellValue(totalSum);
			tStyle = tWBook.createCellStyle();
			tStyle.setDataFormat(tWBook.createDataFormat().getFormat("0.0000"));
			tCell.setCellStyle(tStyle);

			String aPath = tName + aBalYM + ".xls";// + "结算明细"
			aForm.getResponse().reset();
			aForm.getResponse().setContentType("application/vnd.ms-excel;charset=UTF-16");
			aForm.getResponse().setHeader("Content-Disposition",
					"attachment;filename=" + GSBaseManager.toUtf8String(new String(aPath.getBytes("UTF-8"), "UTF-8")));

			// 写到输出流
			OutputStream tOutputStream = aForm.getResponse().getOutputStream();
			tWBook.write(tOutputStream);
			tOutputStream.flush();
			tOutputStream.close();
		} catch (Exception e) {
			e.printStackTrace();
			result = false;
			throw new GSException(e.toString());
		} finally {

		}

		return result;
	}

	/**
	 * 在未结算明细查询页面导出excel文档
	 * 
	 * @param aForm
	 *            页面参数
	 * @param aOrgList
	 *            订货单位
	 * @return
	 * @throws GSException
	 */
	public boolean exportUnbalancedDetail(GSUnBalanceDetlQryForm aForm, ArrayList aOrgList) throws GSException {
		boolean tFlag = false;
		GSUnBalanceDetailQryVO tVO = new GSUnBalanceDetailQryVO();
		try {
			tVO.concentricityId = aForm.getConcentricityId();
			String[] tDateStr = new String[2];
			tDateStr[0] = aForm.orderDeliverDateStr;
			tDateStr[1] = aForm.orderDeliverDateEnd;
			tDateStr = DateUtil.formateDate(tDateStr);
			tVO.deliverGoodsDateStr = tDateStr[0];
			tVO.deliverGoodsDateEnd = tDateStr[1];

			tVO.deliverGoodsId = aForm.getDeliverGoodsId();
			tVO.manufInfo = aForm.getManufInfo();
			tVO.providerShortName = aForm.getProviderName();
			tVO.balanceYM = aForm.getBalanceYM();
			tVO.deptId = aForm.getDeptId();
			tVO.deptCategory = aForm.getDeptCategory();
			GSBalanceMsgDAO tBalMsgDAO = new GSBalanceMsgDAO();
			ArrayList tBalList = tBalMsgDAO.queryBalanceInfo(tVO.deptId, tVO.balanceYM);
			if (tBalList.size() == 1) {
				GSOrderDetailDAO tOrderDtlDAO = new GSOrderDetailDAO();
				GSBalanceMsgBean tBean = (GSBalanceMsgBean) tBalList.get(0);
				tVO.endBalDate = DateUtil.splitSpecChar(tBean.getGs_end_date());
				// aVO.strBalDate =
				// DateUtil.splitSpecChar(tBean.getGs_start_date());
				// 查询已纳入结算的相关明细信息
				ArrayList tRs = tOrderDtlDAO.querySignedDetail(tVO, aOrgList);

				// 写文档
				writeFile(aForm.getDeptCategory(), aForm.getDeptId(), aForm.getBalanceYM(), tRs, aForm);
				tFlag = true;
			} else {
				GSLogWriter.error(this, GSException.E40005_MSG);
				throw new GSException(GSException.E40005, GSException.E40005_MSG);
			}
		} catch (Exception e) {
			e.printStackTrace();
			tFlag = false;
			throw new GSException(e.toString());
		}
		return tFlag;
	}

	/**
	 * 取得历史订单明细
	 * 
	 * @param aOrderVO
	 *            查询参数
	 * @param aOrg
	 *            可查询订货单位
	 * @param pageNo
	 *            页号
	 * @param pageSize
	 *            每页笔数
	 * @return
	 * @throws GSException
	 */
	public ArrayList getHistoryOrderDetail(GSOrderVO aOrderVO, int pageNo, int pageSize) throws GSException {
		ArrayList tList = new ArrayList();
		GSOrderDetailDAO tOrderDAO = new GSOrderDetailDAO();
		ArrayList tRs = tOrderDAO.queryHistoryOrderDetail(aOrderVO, pageNo, pageSize);
		if (tRs.size() > 0) {
			// 重新封装查询结果
			for (int i = 0; i < tRs.size(); i++) {
				GSOrderAnaDetailBean tOrderQryVO = (GSOrderAnaDetailBean) tRs.get(i);
				String[] tStr = new String[14];
				tStr[0] = tOrderQryVO.getGs_order_detail_id();
				tStr[1] = tOrderQryVO.getGs_concentricity_id();
				tStr[2] = tOrderQryVO.getName_product();
				tStr[3] = tOrderQryVO.getSpec();
				tStr[4] = tOrderQryVO.getModel();
				tStr[5] = tOrderQryVO.getProduct_brand();
				tStr[6] = StringUtils.formatEDouble(tOrderQryVO.getGs_order_count(), 2) + tOrderQryVO.getProduct_unit();
				tStr[7] = tOrderQryVO.getGs_order_create_date();
				tStr[8] = tOrderQryVO.getName_warehouse();
				tStr[9] = StringUtils.formatEDouble(tOrderQryVO.getGs_goods_unitprice(), 4);
				tStr[10] = StringUtils.formatEDouble(tOrderQryVO.getGs_goods_unitprice() * tOrderQryVO.getGs_order_count(), 4);
				tStr[11] = tOrderQryVO.getGs_order_tempid_order();
				tStr[12] = tOrderQryVO.getApep_code();
				tStr[13] = tOrderQryVO.getDrawing_piece_code();
				tList.add(tStr);
			}
		}
		return tList;
	}

	// add by Jackey start
	/**
	 * 取得物资公司所有退货订单及明细信息
	 * 
	 * @param aGSOrderVO
	 *            封装订单查询参数的VO对象
	 * @return
	 * @throws GSException
	 */
	public ArrayList getBusRefundOrderAndDetail(GSBusOrderRefundVO aGSBusOrderRefundVO, ArrayList tOrg) throws GSException {
		ArrayList tBusOrderList = new ArrayList();
		GSBusOrderDAO tGSBusOrderDAO = new GSBusOrderDAO();
		ArrayList tList = new ArrayList();
		Connection tConn = null;
		try {
			// 取得DB连接
			tConn = tGSBusOrderDAO.getConnetion();
			String[] tDateStr = new String[2];
			// 取得查询参数订单创建最小日期和最大日期
			tDateStr[0] = aGSBusOrderRefundVO.orderCreateDateStr;
			tDateStr[1] = aGSBusOrderRefundVO.orderCreateDateEnd;
			// 格式化日期
			tDateStr = DateUtil.formateDate(tDateStr);
			aGSBusOrderRefundVO.orderCreateDateStr = tDateStr[0];
			aGSBusOrderRefundVO.orderCreateDateEnd = tDateStr[1];
			// 查询所有订单及明细
			tBusOrderList = tGSBusOrderDAO.queryBusRefundOrder(tConn, aGSBusOrderRefundVO, tOrg);
			if (tBusOrderList.size() > 0) {

				for (int i = 0; i < tBusOrderList.size(); i++) {

					GSBusOrderCancelOfWorkingVO tGSBusOrderCancelOfWorkingVO = (GSBusOrderCancelOfWorkingVO) tBusOrderList.get(i);

					String[] tStr = new String[21];
					// tStr[0] = tGSBusOrderCancelOfWorkingVO.orderid;
					tStr[0] = tGSBusOrderCancelOfWorkingVO.orderdetailid;
					tStr[1] = GSBaseManager.getOrderDetailStatusName(tGSBusOrderCancelOfWorkingVO.orderdetailStatus);
					tStr[2] = tGSBusOrderCancelOfWorkingVO.concentricityId;
					tStr[3] = tGSBusOrderCancelOfWorkingVO.manufactureName;
					tStr[4] = GSBaseManager.getTradeflatName(tGSBusOrderCancelOfWorkingVO.istradeflat);
					tStr[5] = tGSBusOrderCancelOfWorkingVO.manufSpec;
					tStr[6] = tGSBusOrderCancelOfWorkingVO.manufType;
					tStr[7] = tGSBusOrderCancelOfWorkingVO.manufBrand;
					tStr[8] = tGSBusOrderCancelOfWorkingVO.providername;
					tStr[9] = StringUtils.formatEDouble(tGSBusOrderCancelOfWorkingVO.orderCount, 2);
					tStr[10] = tGSBusOrderCancelOfWorkingVO.quantUnit;
					tStr[11] = StringUtils.formatEDouble(tGSBusOrderCancelOfWorkingVO.manufacutreUnitPrice, 4);
					tStr[12] = tGSBusOrderCancelOfWorkingVO.orderDeptName;
					tStr[13] = tGSBusOrderCancelOfWorkingVO.confirmdate;
					tStr[14] = GSBaseManager.getDeliverGoodsTime(tGSBusOrderCancelOfWorkingVO.confirmtime);
					tStr[15] = StringUtils.formatEDouble(tGSBusOrderCancelOfWorkingVO.manufacutreUnitPrice * tGSBusOrderCancelOfWorkingVO.orderCount, 4);
					tStr[16] = tGSBusOrderCancelOfWorkingVO.providerid;
					tStr[17] = tGSBusOrderCancelOfWorkingVO.istradeflat;
					tStr[18] = tGSBusOrderCancelOfWorkingVO.orderid;
					tStr[19] = tGSBusOrderCancelOfWorkingVO.providerid;
					tStr[20] = tGSBusOrderCancelOfWorkingVO.provideristradeflat;
					tList.add(tStr);
				}
			}
		} catch (GSException ge) {
			throw ge;
		} catch (Exception e) {
			GSLogWriter.debug(this, e.toString());
			throw new GSException(GSException.E10041, GSException.E10041_MSG);
		} finally {
			GSBusOrderDAO.close(tConn);
		}
		return tList;
	}

	/**
	 * 巴士物资根据订单编号取得退货订单明细用于详细显示页面
	 * 
	 * @param aOrderId
	 *            订单编号
	 * @return
	 * @throws GSException
	 */
	public ArrayList getOrderDetailOfBusRefund(String aOrderId) throws GSException {
		ArrayList tRs = new ArrayList();
		GSOrderDetailDAO tOrderDetailDAO = new GSOrderDetailDAO();
		// 查询SQL
		StringBuffer tSql = new StringBuffer("select distinct a.GS_ORDER_DETAIL_ID as P1,a.GS_CONCENTRICITY_ID as P2,");
		tSql.append("b.GS_MANUFACTURE_NAME as P3,b.GS_MANUFACTURE_SPEC as P4,b.GS_MANUFACTURE_TYPE as P5,");
		tSql.append("b.GS_MANUFACTURE_BRAND as P6,c.GS_PROVIDER_SHORTNAME as P7,");
		tSql.append("a.GS_ORDER_COUNT as P8,b.GS_QUANT_UNIT as P9,a.GS_GOODS_UNITPRICE as P10,");
		tSql.append("a.GS_DELIVER_GOODS_DATE as P11,a.GS_DELIVER_GOODS_TIME as P12,a.GS_ORDER_DETAIL_STATUS as P13,");
		tSql.append("a.GS_ORDER_TEMPID as P14,b.GS_IS_TRADEFLAT_MANUFACTURE as P15,c.GS_PROVIDER_ID as P16,");
		tSql.append("c.GS_IS_TRADEFLAT_PROVIDER as P17,b.GS_MANUFACTURE_UNITPRICE as P18,b.gs_quality_assure_period as P19 ");
		tSql.append("from GS_ORDER_DETAIL a,GS_MANUFACTURE b,GS_PROVIDER c ");
		tSql.append("where a.GS_ORDER_TEMPID='" + aOrderId + "' and a.GS_CONCENTRICITY_ID=b.GS_CONCENTRICITY_ID ");
		tSql.append("and c.GS_PROVIDER_ID=a.GS_PROVIDER_ID ");
		tSql.append("and a.gs_manufacture_id=b.gs_manufacture_id ");
		// 执行查询
		ArrayList tList = tOrderDetailDAO.queryOrderDetail(tSql.toString(), new GSOrderDetailOfBusVO());
		if (tList.size() > 0) {
			// 封装查询结果
			for (int i = 0; i < tList.size(); i++) {
				String tStr[] = new String[19];
				GSOrderDetailOfBusVO tVO = (GSOrderDetailOfBusVO) tList.get(i);
				tStr[0] = tVO.orderDetailId;
				tStr[1] = tVO.conCentricityId;
				tStr[2] = tVO.manufactureName;
				tStr[3] = tVO.manufSpec;
				tStr[4] = tVO.manufType;
				tStr[5] = tVO.manufBrand;
				tStr[6] = tVO.providerName;
				tStr[7] = StringUtils.formatEDouble(tVO.orderCount, 2);
				tStr[8] = tVO.quantUnit;
				tStr[9] = StringUtils.formatEDouble(tVO.goodUnitprice, 4);
				tStr[10] = StringUtils.formatEDouble(tVO.goodUnitprice * tVO.orderCount, 4);
				tStr[11] = tVO.deliverGoodsDate == null ? "" : tVO.deliverGoodsDate;
				System.out.print(tVO.deliverGoodsTime);
				tStr[12] = GSBaseManager.getDeliverGoodsTime("" + tVO.deliverGoodsTime);
				tStr[13] = GSBaseManager.getOrderDetailStatusName(tVO.orderDetailStatus);
				tStr[14] = tVO.providerId;
				tStr[15] = tVO.isTradeFlatManuf;
				tStr[16] = tVO.isTradeFlatProvider;
				tStr[17] = tVO.orderDetailStatus;
				// tStr[18] = StringUtils.formatEDouble(tVO.manufUnitprice,4);
				tStr[18] = tVO.qualityAssurePeriod;
				tRs.add(tStr);
			}
		}
		return tRs;
	}

	/**
	 * 巴士物资订单退货
	 * 
	 * @param aOrderDetailStatus
	 * @param aOrderDetailId
	 * @return
	 * @throws GSException
	 */
	public static String doRefundBusOrderTask(String aOldStatus, String aOrderDetailStatus, String aOrderDetailId, GSOperatorBean aOperBean, String aOperDate,
			String aRefundcount, String aContents, String aIsTradeFlatManuf, String aIsTradeFlatProv) throws GSException {

		String returnValue = "";
		GSBusOrderDAO tGSBusOrderDAO = new GSBusOrderDAO();
		Connection tConn = null;
		try {
			tConn = tGSBusOrderDAO.getConnetion();
			tConn.setAutoCommit(false);
			returnValue = tGSBusOrderDAO.doRefundBusOrder(tConn, aOrderDetailStatus, aOrderDetailId, aOperBean, aOperDate, aRefundcount, aContents);

			if (returnValue != null && !returnValue.equals("")) {
				tConn.commit();
			} else {
				GSLogWriter.error("修改订单状态为取消时失败");
			}
		} catch (GSException ge) {
			try {
				if (tConn != null) {
					tConn.rollback();
				}
			} catch (SQLException se) {
				se.printStackTrace();
			}
			throw ge;
		} catch (Exception e) {
			try {
				if (tConn != null) {
					tConn.rollback();
				}
			} catch (SQLException se) {
				se.printStackTrace();
			}
			GSLogWriter.error(e.toString());
			throw new GSException(GSException.E10066, GSException.E10066_MSG);
		} finally {
			GSBusOrderDAO.close(tConn);
		}
		return returnValue;
	}

	/**
	 * 巴士物资根据订单编号取得退货订单明细用于详细显示页面
	 * 
	 * @param aOrderId
	 *            订单编号
	 * @return
	 * @throws GSException
	 */
	public ArrayList getRefundOrderDetail(String aOrderId) throws GSException {
		ArrayList tRs = new ArrayList();
		GSOrderDetailDAO tOrderDetailDAO = new GSOrderDetailDAO();
		// 查询SQL
		StringBuffer tSql = new StringBuffer("select distinct a.GS_ORDER_DETAIL_ID as P1,a.GS_CONCENTRICITY_ID as P2,");
		tSql.append("b.GS_MANUFACTURE_NAME as P3,b.GS_MANUFACTURE_SPEC as P4,b.GS_MANUFACTURE_TYPE as P5,");
		tSql.append("b.GS_MANUFACTURE_BRAND as P6,c.GS_PROVIDER_SHORTNAME as P7,");
		tSql.append("a.REQUEST_BACK_QTY as P8,b.GS_QUANT_UNIT as P9,a.GS_GOODS_UNITPRICE as P10,");
		tSql.append("a.REQUEST_BACK_TIME as P11,a.GS_DELIVER_GOODS_TIME as P12,a.GS_ORDER_DETAIL_STATUS as P13,");
		tSql.append("a.GS_ORDER_TEMPID as P14,b.GS_IS_TRADEFLAT_MANUFACTURE as P15,c.GS_PROVIDER_ID as P16,");
		tSql.append("c.GS_IS_TRADEFLAT_PROVIDER as P17,b.GS_MANUFACTURE_UNITPRICE as P18,b.gs_quality_assure_period as P19,");
		tSql.append("a.LINK_ORDER_DETAIL_ID as P20,a.REQUEST_BACK_PERSON as P21,a.REQUEST_BACK_REASON as P22,");
		tSql.append("a.DISPOSE_BACK_TIME as P23,a.DISPOSE_BACK_PERSON as P24,a.DISPOSE_BACK_REASON as P25,");
		tSql.append("a.ALREADY_BACK_QTY as P26,a.DISPOSE_CANCEL_REASON as P27,a.DISPOSE_CANCEL_TIME as P28,a.DISPOSE_CANCEL_PERSON as P29");
		tSql.append(" from GS_ORDER_DETAIL a,GS_MANUFACTURE b,GS_PROVIDER c ");
		tSql.append("where a.LINK_ORDER_DETAIL_ID='" + aOrderId + "' and a.GS_CONCENTRICITY_ID=b.GS_CONCENTRICITY_ID ");
		tSql.append("and c.GS_PROVIDER_ID=a.GS_PROVIDER_ID ");
		tSql.append("and a.gs_manufacture_id=b.gs_manufacture_id order by P1");
		// 执行查询
		ArrayList tList = tOrderDetailDAO.queryOrderDetail(tSql.toString(), new GSOrderRefundDetailOfBusVO());
		if (tList.size() > 0) {
			// 封装查询结果
			for (int i = 0; i < tList.size(); i++) {
				String tStr[] = new String[30];
				GSOrderRefundDetailOfBusVO tVO = (GSOrderRefundDetailOfBusVO) tList.get(i);
				tStr[0] = tVO.orderDetailId;
				tStr[1] = tVO.conCentricityId;
				tStr[2] = tVO.manufactureName;
				tStr[3] = tVO.manufSpec;
				tStr[4] = tVO.manufType;
				tStr[5] = tVO.manufBrand;
				tStr[6] = tVO.providerName;
				tStr[7] = StringUtils.formatEDouble(tVO.requestBackQty, 2);
				tStr[8] = tVO.quantUnit;
				tStr[9] = StringUtils.formatEDouble(tVO.goodUnitprice, 4);
				tStr[10] = StringUtils.formatEDouble(tVO.goodUnitprice * tVO.requestBackQty, 4);
				tStr[11] = tVO.requestBackTime == null ? "" : tVO.requestBackTime;
				System.out.print(tVO.deliverGoodsTime);
				tStr[12] = GSBaseManager.getDeliverGoodsTime("" + tVO.deliverGoodsTime);
				tStr[13] = GSBaseManager.getOrderDetailStatusName(tVO.orderDetailStatus);
				tStr[14] = tVO.providerId;
				tStr[15] = tVO.isTradeFlatManuf;
				tStr[16] = tVO.isTradeFlatProvider;
				tStr[17] = tVO.orderDetailStatus;
				// tStr[18] = StringUtils.formatEDouble(tVO.manufUnitprice,4);
				tStr[18] = tVO.qualityAssurePeriod;

				tStr[19] = tVO.linkOrderDetailId;
				tStr[20] = tVO.requestBackPerson;
				tStr[21] = tVO.requestBackReason;
				tStr[22] = tVO.disposeBackTime;
				tStr[23] = tVO.disposeBackPerson;
				tStr[24] = tVO.disposeBackReason;
				tStr[25] = StringUtils.formatEDouble(tVO.alreadyBackQty, 2);
				tStr[26] = tVO.disposeCancleReason;
				tStr[27] = tVO.disposeCancleTime;
				tStr[28] = tVO.disposeCanclePerson;
				tStr[29] = tVO.orderid;

				tRs.add(tStr);
			}
		}
		return tRs;
	}

	// add by Jackey end

	// add by wangp start
	public ArrayList getOrderDetailsByOrderDetailIds(String[] aOrderDetailIds) throws GSException {
		GSOrderDetailDAO tGSOrderDetailDAO = new GSOrderDetailDAO();
		return tGSOrderDetailDAO.queryOrderDetailByDetailIds(aOrderDetailIds);
	}

	// add by wangp end

	/**
	 * 运营公司级申购综合查询订单
	 * 
	 * @param aOrderVO
	 *            传入的查询参数VO对象
	 * @param aOrg
	 *            可查询订货单位ArrayList对象
	 * @param pageNo
	 *            页号
	 * @param pageSize
	 *            页大小
	 * @return
	 * @throws GSException
	 */
	public ArrayList getOrderDetailByOpt_r(GSOrderVO aOrderVO, int pageNo, int pageSize) throws GSException {

		String[] tDateStr = new String[2];
		// 取得查询参数订单创建最小日期和最大日期
		tDateStr[0] = aOrderVO.orderCreateDateLowLimie;
		tDateStr[1] = aOrderVO.orderCreateDateUprLimie;
		// 格式化日期
		tDateStr = DateUtil.formateDate(tDateStr);
		aOrderVO.orderCreateDateLowLimie = tDateStr[0];
		aOrderVO.orderCreateDateUprLimie = tDateStr[1];

		GSOrderDetailDAO tOrderDtlDAO = new GSOrderDetailDAO();
		// 执行查询
		ArrayList tRs = tOrderDtlDAO.queryOrderDetailByOpt_r(aOrderVO, pageNo, pageSize);

		return tRs;
	}

	/**
	 * 运营公司级申购综合查询订单取得总笔数
	 * 
	 * @param aOrderVO
	 *            传入的查询参数VO对象
	 * @param aOrg
	 *            可查询订货单位ArrayList对象
	 * @return
	 * @throws GSException
	 */
	public int getOrderDetailCountByOpt_r(GSOrderVO aOrderVO) throws GSException {
		String[] tDateStr = new String[2];
		// 取得查询参数订单创建最小日期和最大日期
		tDateStr[0] = aOrderVO.orderCreateDateLowLimie;
		tDateStr[1] = aOrderVO.orderCreateDateUprLimie;
		// 格式化日期
		tDateStr = DateUtil.formateDate(tDateStr);
		aOrderVO.orderCreateDateLowLimie = tDateStr[0];
		aOrderVO.orderCreateDateUprLimie = tDateStr[1];

		GSOrderDetailDAO tOrderDtlDAO = new GSOrderDetailDAO();
		int size = tOrderDtlDAO.queryOrderDetailCountByOpt_r(aOrderVO);
		return size;
	}

	/**
	 * 运营公司级申购综合查询订单导出Excel
	 * 
	 * @param aOrderVO
	 *            传入的查询参数VO对象
	 * @param aOrg
	 *            可查询订货单位ArrayList对象
	 * @param pageNo
	 *            页号
	 * @param pageSize
	 *            页大小
	 * @return
	 * @throws GSException
	 */
	public static boolean getOrderDetailDownexcel(GSOrderReceiveQueryForm tForm, GSOrderVO aOrderVO, int pageNo, int pageSize)
	throws GSException {
		boolean rvalue = false;
		String[] tDateStr = new String[2];
		// 取得查询参数订单创建最小日期和最大日期
		tDateStr[0] = aOrderVO.orderCreateDateLowLimie;
		tDateStr[1] = aOrderVO.orderCreateDateUprLimie;
		// 格式化日期
		tDateStr = DateUtil.formateDate(tDateStr);
		aOrderVO.orderCreateDateLowLimie = tDateStr[0];
		aOrderVO.orderCreateDateUprLimie = tDateStr[1];

		GSOrderDetailDAO tOrderDtlDAO = new GSOrderDetailDAO();
		// 执行查询
		ArrayList tRs = tOrderDtlDAO.queryOrderDetailByOpt_r(aOrderVO, pageNo, pageSize);
		if (tRs.size() > 0) {
			// 重新封装查询结果
			OutputStream tOutputStream = null;
			jxl.write.WritableWorkbook book = null;
			try {
				// 打开文件

				String fileName = "申购单查询结果.xls";

				tForm.getResponse().setHeader("Content-Type", "application/force-download");
				tForm.getResponse().setHeader("Content-Disposition", "attachment; filename=" + new String(fileName.getBytes("gb2312"), "ISO-8859-1"));

				tForm.getResponse().setHeader("Content-Description", "申购单查询结果");

				tOutputStream = tForm.getResponse().getOutputStream();
				book = Workbook.createWorkbook(tOutputStream);
				jxl.write.WritableSheet sheet = book.createSheet("订单信息列表", 0);
				Label label0 = new Label(0, 0, "申购单明细编号");
				Label label1 = new Label(1, 0, "送货单号");
				Label label2 = new Label(2, 0, "集中编码");
				Label label3 = new Label(3, 0, "产品名称");
				Label label4 = new Label(4, 0, "供应商");
				Label label5 = new Label(5, 0, "规格");
				Label label6 = new Label(6, 0, "型号");
				Label label7 = new Label(7, 0, "品牌");
				Label label8 = new Label(8, 0, "图件号");
				Label label9 = new Label(9, 0, "订货数量");
				Label label10 = new Label(10, 0, "申购单明细状态");
				Label label11 = new Label(11, 0, "要求送货时间");
				Label label12 = new Label(12, 0, "价格（元）");
				Label label13 = new Label(13, 0, "总价（元）");
				Label label14 = new Label(14, 0, "配送数量");
				Label label15 = new Label(15, 0, "签收数量");
				Label label16 = new Label(16, 0, "实际送货日期");
				Label label17 = new Label(17, 0, "订货单位");
				Label label18 = new Label(18, 0, "送货地址");
				Label label19 = new Label(19, 0, "结算模式");
				;
				// 将定义好的单元格添加到工作表中
				sheet.addCell(label0);
				sheet.addCell(label1);
				sheet.addCell(label2);
				sheet.addCell(label3);
				sheet.addCell(label4);
				sheet.addCell(label5);
				sheet.addCell(label6);
				sheet.addCell(label7);
				sheet.addCell(label8);
				sheet.addCell(label9);
				sheet.addCell(label10);
				sheet.addCell(label11);
				sheet.addCell(label12);
				sheet.addCell(label13);
				sheet.addCell(label14);
				sheet.addCell(label15);
				sheet.addCell(label16);
				sheet.addCell(label17);
				sheet.addCell(label18);
				sheet.addCell(label19);
				for (int i = 0; i < tRs.size(); i++) {
					GSOrderAnaDetailBean tOrderQryVO = (GSOrderAnaDetailBean) tRs.get(i);
					// 将定义好的单元格添加到工作表中
					sheet.addCell(new Label(0, i + 1, tOrderQryVO.getGs_order_detail_id())); // 订单明细编号
					sheet.addCell(new Label(1, i + 1, tOrderQryVO.getGs_deliver_goods_id())); // 送货单号
					sheet.addCell(new Label(2, i + 1, tOrderQryVO.getGs_concentricity_id())); // 集中编码
					sheet.addCell(new Label(3, i + 1, tOrderQryVO.getName_product())); // 产品名称
					sheet.addCell(new Label(4, i + 1, tOrderQryVO.getName())); // 供应商
					sheet.addCell(new Label(5, i + 1, tOrderQryVO.getSpec())); // 规格
					sheet.addCell(new Label(6, i + 1, tOrderQryVO.getModel())); // 型号
					sheet.addCell(new Label(7, i + 1, tOrderQryVO.getProduct_brand())); // 品牌
					sheet.addCell(new Label(8, i + 1, tOrderQryVO.getDrawing_piece_code())); // 图件号
					sheet.addCell(new Label(9, i + 1, StringUtils.formatEDouble(tOrderQryVO.getGs_order_count(), 2)+" "+tOrderQryVO.getProduct_unit())); // 订货数量
					sheet.addCell(new Label(10, i + 1, GSBaseManager.getOrderDetailStatusName(tOrderQryVO.getGs_order_detail_status()))); // 申购单状态明细
					sheet.addCell(new Label(11, i + 1, tOrderQryVO.getGs_deliver_goods_date()+" "+GSBaseManager.getDeliverGoodsTime(tOrderQryVO.getGs_deliver_goods_time()))); // 要求送货时间
					sheet.addCell(new Label(12, i + 1,StringUtils.formatEDouble(tOrderQryVO.getGs_goods_unitprice(), 4))); // 价格（元）
					sheet.addCell(new Label(13, i + 1, StringUtils.formatEDouble(tOrderQryVO.getGs_goods_unitprice()*tOrderQryVO.getGs_order_count(), 4))); // 总价（元）
					sheet.addCell(new Label(14, i + 1, StringUtils.formatEDouble(tOrderQryVO.getGs_deliver_goods_counts(),2)+" "+tOrderQryVO.getProduct_unit())); // 配送数量
					sheet.addCell(new Label(15, i + 1, tOrderQryVO.getGs_signin_count()!=0?StringUtils.formatEDouble(tOrderQryVO.getGs_signin_count(), 2):"")); // 签收数量
					sheet.addCell(new Label(16, i + 1, tOrderQryVO.getGs_signin_date())); // 签收日期
					sheet.addCell(new Label(17, i + 1, tOrderQryVO.getName_warehouse())); // 订货单位
					sheet.addCell(new Label(18, i + 1, tOrderQryVO.getAddress_warehouse())); // 订货地址
					sheet.addCell(new Label(19, i + 1, DefineDic.getBalanceMode(tOrderQryVO.getGs_balance_mode()))); // 结算模式
				}
				// 写入数据并关闭文件
				book.write();
				tOutputStream.flush();
				rvalue = true;
			} catch (Exception e) {
				System.out.println(e);
				GSLogWriter.error(e.getLocalizedMessage(), e);
			} finally {

				if (book != null) {
					try {
						book.close();
					} catch (WriteException e) {

						e.printStackTrace();
					} catch (IOException e) {

						e.printStackTrace();
					}
				}
				if (tOutputStream != null) {
					try {
						tOutputStream.close();
					} catch (IOException e) {

						e.printStackTrace();
					}
				}
			}
		}
		return rvalue;
	}

	/**
	 * 订单签收
	 * 
	 * @param GSOperatorBean
	 *            操作员Bean
	 * @param ArrayList
	 *            签收数据列表
	 * @throws GSException
	 */
	public String modifyOrder_r(GSOperatorBean operBean, ArrayList ary) throws GSException {
		GSOrderDAO ordd = new GSOrderDAO();
		Connection conn = null;
		int err = 0;
		int ok = 0;
		String msg = "";
		boolean tFlag = false;
		try {
			conn = ordd.getConnetion();
			conn.setAutoCommit(false);
			String sql_a = "update GS_ORDER_DETAIL set GS_SIGNIN_COUNT=?,GS_SIGNIN_DATE=?,GS_SIGNIN_PERSON=?,"
				+ "GS_SIGNIN_EXPLAIN=?,GS_ORDER_DETAIL_STATUS=? where GS_ORDER_DETAIL_ID =?";
			if (ary != null) {
				for (int i = 0; i < ary.size(); i++) {
					GSOrderReceiveQueryVO vo = (GSOrderReceiveQueryVO) ary.get(i);
					Object[] obj = { String.valueOf(vo.cursigninCount), vo.cursigninDate, vo.signin_person, vo.signin_explain, "12", vo.orderDetailId };
					tFlag = ordd.executeUpdate(conn, sql_a, obj);
					if (tFlag) {
						// 执行订单提交,将签收信息提交到APEP平台
						String tRs = "";
						GSBusOrderProcesser tGSBusOrderProcesser = new GSBusOrderProcesser();
						tRs = tGSBusOrderProcesser.submitOrderReciveInfoToApep(vo, operBean);
						if ("1".equals(tRs)) {
							conn.commit();
							ok++;
						} else {
							conn.rollback();
							err++;
							GSLogWriter.error("订单签收提交数据失败");
						}
					} else {
						conn.rollback();
						throw new GSException("更新订单明细错误");
					}
				}
				if (err == 0) {
					msg = "有" + ok + "笔订单签收成功";
				} else {
					msg = "有" + ok + "笔订单签收成功,有" + err + "笔订单签收并提交到APEP失败。";
				}
			}
		} catch (Exception e) {
			GSLogWriter.error(this, e);
			try {
				conn.rollback();
			} catch (SQLException ex) {
			}
			throw new GSException(GSException.E10043, GSException.E10043_MSG);
		} finally {
			try {
				conn.setAutoCommit(true);
			} catch (Exception e) {
			}
			GSOrderDAO.close(conn);

		}
		return msg;
	}
}
